diff options
-rw-r--r-- | mysql-test/r/insert.result | 24 | ||||
-rw-r--r-- | mysql-test/t/cast.test | 2 | ||||
-rw-r--r-- | mysql-test/t/insert.test | 4 | ||||
-rw-r--r-- | sql/field.cc | 2 |
4 files changed, 18 insertions, 14 deletions
diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result index 658093f9f8c..a54fa6f0314 100644 --- a/mysql-test/r/insert.result +++ b/mysql-test/r/insert.result @@ -538,23 +538,23 @@ Warnings: Warning 1265 Data truncated for column 'c' at row 1 SELECT * FROM t1; a b c -9.999999000000000748 10 10 +9.999999 10 10 1.225e-05 1.2e-05 1e-0 0.0001225 0.00012 NULL -0.122499999999999998 0.1225 NULL -0.122587699999999994 0.12259 NULL +0.1225 0.1225 NULL +0.1225877 0.12259 NULL 12.25 12.25 NULL 12.25 12.25 12.2 122500 122500 NULL 12250000000 1.2e+10 NULL -1225000000000000 1.2e+15 NULL +1.225e+15 1.2e+15 NULL 5000000 5000000 NULL 1.25e+78 1.2e+78 NULL 1.25e-94 1.2e-94 NULL 1.25e+203 1e+203 NULL 1.25e-175 1e-175 NULL -1.225000000000000089 NULL 1.23 -1.370000000000000107 NULL 1.37 +1.225 NULL 1.23 +1.37 NULL 1.37 -1.37 NULL -1.3 0.00187 NULL 0.00 -0.0187 NULL -0.0 @@ -592,23 +592,23 @@ INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0); INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0); SELECT * FROM t1; a b c -9.999999000000000748 10 9.999 +9.999999 10 9.999 1.225e-05 1.2e-05 1e-05 0.0001225 0.00012 NULL -0.122499999999999998 0.1225 NULL -0.122587699999999994 0.12259 NULL +0.1225 0.1225 NULL +0.1225877 0.12259 NULL 12.25 12.25 NULL 12.25 12.25 12.25 122500 122500 NULL 12250000000 1.2e+10 NULL -1225000000000000 1.2e+15 NULL +1.225e+15 1.2e+15 NULL 5000000 5000000 NULL 1.25e+78 1.2e+78 NULL 1.25e-94 1.2e-94 NULL 1.25e+203 1e+203 NULL 1.25e-175 1e-175 NULL -1.225000000000000089 NULL 1.225 -1.370000000000000107 NULL 1.37 +1.225 NULL 1.225 +1.37 NULL 1.37 -1.37 NULL -1.37 0.00187 NULL 0.002 -0.0187 NULL -0.01 diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index a140fe1d646..5563e260a06 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -177,6 +177,8 @@ select cast(1.0e+300 as signed int); CREATE TABLE t1 (f1 double); INSERT INTO t1 SET f1 = -1.0e+30 ; INSERT INTO t1 SET f1 = +1.0e+30 ; +# Expected result is +-1e+30, but Windows returns +-1e+030. +--replace_result 1e+030 1e+30 SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1; DROP TABLE t1; diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index bc75192cbd5..ea48db95df3 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -420,7 +420,9 @@ INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3); INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2); INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0); INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0); - +# Expected results are "12.2" and "1.2e+78", but Windows returns "12.3" and +# "1.3e+78" due to different rounding rules +--replace_result 12.3 12.2 1.3e+78 1.2e+78 SELECT * FROM t1; DROP TABLE t1; diff --git a/sql/field.cc b/sql/field.cc index 00c12ad7d5b..9e57e27394e 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6306,7 +6306,7 @@ int Field_str::store(double nr) if (exp >= (int) digits || exp < -4) digits= max(0, (int) (max_length - 5 - (exp >= 100 || exp <= -100))); - length= (uint) my_sprintf(buff, (buff, "%-.*g", digits, nr)); + length= (uint) my_sprintf(buff, (buff, "%-.*g", min(digits, DBL_DIG ), nr)); #ifdef __WIN__ /* |