diff options
-rw-r--r-- | sql/item.cc | 4 | ||||
-rw-r--r-- | sql/item_func.h | 4 | ||||
-rw-r--r-- | sql/item_sum.cc | 6 | ||||
-rw-r--r-- | sql/item_sum.h | 8 |
4 files changed, 11 insertions, 11 deletions
diff --git a/sql/item.cc b/sql/item.cc index 94dea1a7dd7..8a55049df84 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2467,7 +2467,7 @@ longlong Item_param::val_int() { switch (state) { case REAL_VALUE: - return (longlong) (value.real + (value.real > 0 ? 0.5 : -0.5)); + return (longlong) rint(value.real); case INT_VALUE: return value.integer; case DECIMAL_VALUE: @@ -5439,7 +5439,7 @@ void Item_cache_real::store(Item *item) longlong Item_cache_real::val_int() { DBUG_ASSERT(fixed == 1); - return (longlong) (value+(value > 0 ? 0.5 : -0.5)); + return (longlong) rint(value); } diff --git a/sql/item_func.h b/sql/item_func.h index ed39cb86d3e..76647fd5cb2 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -199,7 +199,7 @@ public: String *val_str(String*str); my_decimal *val_decimal(my_decimal *decimal_value); longlong val_int() - { DBUG_ASSERT(fixed == 1); return (longlong) val_real(); } + { DBUG_ASSERT(fixed == 1); return (longlong) rint(val_real()); } enum Item_result result_type () const { return REAL_RESULT; } void fix_length_and_dec() { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); } @@ -943,7 +943,7 @@ class Item_func_udf_float :public Item_udf_func longlong val_int() { DBUG_ASSERT(fixed == 1); - return (longlong) Item_func_udf_float::val_real(); + return (longlong) rint(Item_func_udf_float::val_real()); } my_decimal *val_decimal(my_decimal *dec_buf) { diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 506d2a16108..626eb63d04f 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -452,7 +452,7 @@ longlong Item_sum_sum::val_int() &result); return result; } - return (longlong) val_real(); + return (longlong) rint(val_real()); } @@ -1285,7 +1285,7 @@ longlong Item_sum_hybrid::val_int() return sum_int; } default: - return (longlong) Item_sum_hybrid::val_real(); + return (longlong) rint(Item_sum_hybrid::val_real()); } } @@ -2001,7 +2001,7 @@ double Item_avg_field::val_real() longlong Item_avg_field::val_int() { - return (longlong) val_real(); + return (longlong) rint(val_real()); } diff --git a/sql/item_sum.h b/sql/item_sum.h index 87cc248e5e4..2c2bcedab9b 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -126,7 +126,7 @@ public: longlong val_int() { DBUG_ASSERT(fixed == 1); - return (longlong) val_real(); /* Real as default */ + return (longlong) rint(val_real()); /* Real as default */ } String *val_str(String*str); my_decimal *val_decimal(my_decimal *); @@ -392,7 +392,7 @@ public: bool add(); double val_real(); // In SPs we might force the "wrong" type with select into a declare variable - longlong val_int() { return (longlong)val_real(); } + longlong val_int() { return (longlong) rint(val_real()); } my_decimal *val_decimal(my_decimal *); String *val_str(String *str); void reset_field(); @@ -421,7 +421,7 @@ public: enum Type type() const {return FIELD_VARIANCE_ITEM; } double val_real(); longlong val_int() - { /* can't be fix_fields()ed */ return (longlong) val_real(); } + { /* can't be fix_fields()ed */ return (longlong) rint(val_real()); } String *val_str(String*); my_decimal *val_decimal(my_decimal *); bool is_null() { (void) val_int(); return null_value; } @@ -699,7 +699,7 @@ class Item_sum_udf_float :public Item_udf_sum longlong val_int() { DBUG_ASSERT(fixed == 1); - return (longlong) Item_sum_udf_float::val_real(); + return (longlong) rint(Item_sum_udf_float::val_real()); } double val_real(); String *val_str(String*str); |