diff options
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 89f9111101a..db2aa735b0e 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1880,22 +1880,16 @@ void Item_func_round::fix_length_and_dec() } } -double Item_func_round::real_op() +double my_double_round(double value, int dec, bool truncate) { - double value= args[0]->val_real(); - int dec=(int) args[1]->val_int(); - if (dec > 0) - decimals= dec; // to get correct output - uint abs_dec=abs(dec); double tmp; + uint abs_dec= abs(dec); /* tmp2 is here to avoid return the value with 80 bit precision This will fix that the test round(0.1,1) = round(0.1,1) is true */ volatile double tmp2; - if ((null_value=args[0]->null_value || args[1]->null_value)) - return 0.0; tmp=(abs_dec < array_elements(log_10) ? log_10[abs_dec] : pow(10.0,(double) abs_dec)); @@ -1912,6 +1906,18 @@ double Item_func_round::real_op() } +double Item_func_round::real_op() +{ + double value= args[0]->val_real(); + int dec= (int) args[1]->val_int(); + + if (!(null_value= args[0]->null_value || args[1]->null_value)) + return my_double_round(value, dec, truncate); + + return 0.0; +} + + longlong Item_func_round::int_op() { longlong value= args[0]->val_int(); |