summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2003-03-10 12:00:19 +0200
committerunknown <monty@narttu.mysql.fi>2003-03-10 12:00:19 +0200
commit66e8db8241bfcad048d08fa1a24532fae8ee5f0a (patch)
tree2a98237c202bf25f13398e06acba38f5605b6c60 /sql/item_func.cc
parent065bedc5d45fbce52c55feb2c8cc2223652e3d37 (diff)
downloadmariadb-git-66e8db8241bfcad048d08fa1a24532fae8ee5f0a.tar.gz
Fix that round(0.1,1) == round(0.1,1)
sql/slave.cc: Fixed problem with --debug output in handle_slave
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index ef629098d2a..d5b7869cbcb 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -679,20 +679,28 @@ double Item_func_round::val()
double value=args[0]->val();
int dec=(int) args[1]->val_int();
uint abs_dec=abs(dec);
+ double tmp;
+ /*
+ 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;
- double tmp=(abs_dec < array_elements(log_10) ?
- log_10[abs_dec] : pow(10.0,(double) abs_dec));
+ tmp=(abs_dec < array_elements(log_10) ?
+ log_10[abs_dec] : pow(10.0,(double) abs_dec));
if (truncate)
{
if (value >= 0)
- return dec < 0 ? floor(value/tmp)*tmp : floor(value*tmp)/tmp;
+ tmp2= dec < 0 ? floor(value/tmp)*tmp : floor(value*tmp)/tmp;
else
- return dec < 0 ? ceil(value/tmp)*tmp : ceil(value*tmp)/tmp;
+ tmp2= dec < 0 ? ceil(value/tmp)*tmp : ceil(value*tmp)/tmp;
}
- return dec < 0 ? rint(value/tmp)*tmp : rint(value*tmp)/tmp;
+ else
+ tmp2=dec < 0 ? rint(value/tmp)*tmp : rint(value*tmp)/tmp;
+ return tmp2;
}