Changeset: 76e085af5b55 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=76e085af5b55
Modified Files:
        gdk/gdk_calc.c
        sql/backends/monet5/sql_cast.c
        sql/backends/monet5/sql_cast_impl_int.h
        sql/backends/monet5/sql_fround.c
Branch: default
Log Message:

Merge with Dec2016 branch.


diffs (82 lines):

diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c
--- a/gdk/gdk_calc.c
+++ b/gdk/gdk_calc.c
@@ -13454,6 +13454,20 @@ convert_##TYPE1##_##TYPE2(const TYPE1 *s
 #define roundflt(x)    roundf(x)
 #define rounddbl(x)    round(x)
 #endif
+
+#ifndef HAVE_ROUND
+static inline double
+round(double val)
+{
+       /* round to nearest integer, away from zero */
+       if (val < 0)
+               return -floor(-val + 0.5);
+       else
+               return floor(val + 0.5);
+}
+#define roundf(x)      ((float)round((double)(x)))
+#endif
+
 #define convertimpl_reduce_float(TYPE1, TYPE2)                         \
 static BUN                                                             \
 convert_##TYPE1##_##TYPE2(const TYPE1 *src, TYPE2 *restrict dst, BUN cnt, \
diff --git a/sql/backends/monet5/sql_cast.c b/sql/backends/monet5/sql_cast.c
--- a/sql/backends/monet5/sql_cast.c
+++ b/sql/backends/monet5/sql_cast.c
@@ -465,6 +465,19 @@ SQLbatstr_cast(Client cntxt, MalBlkPtr m
        return msg;
 }
 
+#ifndef HAVE_ROUND
+static inline double
+round(double val)
+{
+       /* round to nearest integer, away from zero */
+       if (val < 0)
+               return -floor(-val + 0.5);
+       else
+               return floor(val + 0.5);
+}
+#define roundf(x)      ((float)round((double)(x)))
+#endif
+
 /* up casting */
 
 #define TP1 bte
diff --git a/sql/backends/monet5/sql_cast_impl_int.h 
b/sql/backends/monet5/sql_cast_impl_int.h
--- a/sql/backends/monet5/sql_cast_impl_int.h
+++ b/sql/backends/monet5/sql_cast_impl_int.h
@@ -48,7 +48,7 @@ FUN(do_,TP1,_dec2dec_,TP2) (TP2 *restric
                        GDKfree(buf);
                        return msg;
                }
-               val *= scales[s2 - s1];
+               val *= (TP1) scales[s2 - s1];
        } else if (s2 < s1) {
                if (val / scales[s1 - s2] <= GDKmin(TP2) ||
                    val / scales[s1 - s2] > GDKmax(TP2)) {
@@ -75,9 +75,9 @@ FUN(do_,TP1,_dec2dec_,TP2) (TP2 *restric
        *res = (TP2) val;
 #else
        if (s2 > s1) {
-               r *= scales[s2 - s1];
+               r *= (TP2) scales[s2 - s1];
        } else if (s2 < s1) {
-               r = (TP1) ((r
+               r = (TP2) ((r
 #ifndef TRUNCATE_NUMBERS
                              + (val < 0 ? -5 : 5) * scales[s1 - s2 - 1]
 #endif
diff --git a/sql/backends/monet5/sql_fround.c b/sql/backends/monet5/sql_fround.c
--- a/sql/backends/monet5/sql_fround.c
+++ b/sql/backends/monet5/sql_fround.c
@@ -22,7 +22,6 @@
 #include "clients.h"
 #include "mal_instruction.h"
 
-/* Windows doesn't have round or trunc, but it does have floor and ceil */
 #ifndef HAVE_ROUND
 static inline double
 round(double val)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to