mirror of
https://github.com/MariaDB/server.git
synced 2026-04-29 03:35:34 +02:00
Fix for bug #15936: "round" differs on Windows to Unix
Both of our own implementations of rint(3) were inconsistent with the most common behavior of rint() on those platforms that have it: round to nearest, break ties by rounding to nearest even. Fixed by leaving just one implementation of rint() in our source tree, and changing its behavior to match the most common native implementations on other platforms. configure.in: Added checks for fenv.h and fesetround(). include/config-win.h: Removed the incorrect implementation of rint() for Windows. include/my_global.h: Added an rint() implementation for platforms that do not have it. mysql-test/r/func_math.result: Added a test case for bug #15936. mysql-test/t/func_math.test: Added a test case for bug #15936. sql/mysqld.cc: Explicitly set the FPU rounding mode with fesetround().
This commit is contained in:
parent
ddf6ac40ea
commit
0e62c9aa63
6 changed files with 113 additions and 36 deletions
|
|
@ -360,4 +360,34 @@ SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1;
|
|||
a DIV 2
|
||||
0
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a DOUBLE);
|
||||
INSERT INTO t1 VALUES (-1.1), (1.1),
|
||||
(-1.5), (1.5),
|
||||
(-1.9), (1.9),
|
||||
(-2.1), (2.1),
|
||||
(-2.5), (2.5),
|
||||
(-2.9), (2.9),
|
||||
# Check numbers with absolute values > 2^53 - 1
|
||||
# (see comments for MAX_EXACT_INTEGER)
|
||||
(-1e16 - 0.5), (1e16 + 0.5),
|
||||
(-1e16 - 1.5), (1e16 + 1.5);
|
||||
SELECT a, ROUND(a) FROM t1;
|
||||
a ROUND(a)
|
||||
-1.1 -1
|
||||
1.1 1
|
||||
-1.5 -2
|
||||
1.5 2
|
||||
-1.9 -2
|
||||
1.9 2
|
||||
-2.1 -2
|
||||
2.1 2
|
||||
-2.5 -2
|
||||
2.5 2
|
||||
-2.9 -3
|
||||
2.9 3
|
||||
-1e+16 -10000000000000000
|
||||
1e+16 10000000000000000
|
||||
-1e+16 -10000000000000002
|
||||
1e+16 10000000000000002
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue