summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2002-05-31 15:22:38 +0300
committerunknown <monty@hundin.mysql.fi>2002-05-31 15:22:38 +0300
commit0ceaf6d2c28f4f639a0ba5c329964e4dbe71cb7f (patch)
tree85c51f351e6086eebde739636a64e7ab09b85277 /sql/item_func.cc
parent2c058d84784c67bd514ad6c879333d2c9aac8161 (diff)
downloadmariadb-git-0ceaf6d2c28f4f639a0ba5c329964e4dbe71cb7f.tar.gz
Portability fixes for SCO and HPUX
Change TRUNCATE(number) to truncate towards zero for negative numbers Fix NULL handling for DESCRIBE table_name Docs/manual.texi: Update of TRUNCATE() information configure.in: Fix for HPUX extra/resolveip.c: Fix for SCO include/my_net.h: Fix for HPUX libmysql/libmysql.c: Removed warning on HPUX 10.20 mysql-test/r/func_math.result: Test of new TRUNCATE handling mysql-test/t/func_math.test: Test of new TRUNCATE handling mysys/my_gethostbyname.c: Portability fix sql/item_func.cc: Change TRUNCATE(number) to truncate towards zero for negative numbers sql/sql_show.cc: Fix NULL handling for DESCRIBE table_name
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 9180cccabcf..b73436afbcf 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -601,7 +601,12 @@ double Item_func_round::val()
log_10[abs_dec] : pow(10.0,(double) abs_dec));
if (truncate)
- return dec < 0 ? floor(value/tmp)*tmp : floor(value*tmp)/tmp;
+ {
+ if (value >= 0)
+ return dec < 0 ? floor(value/tmp)*tmp : floor(value*tmp)/tmp;
+ else
+ return dec < 0 ? ceil(value/tmp)*tmp : ceil(value*tmp)/tmp;
+ }
return dec < 0 ? rint(value/tmp)*tmp : rint(value*tmp)/tmp;
}