diff options
Diffstat (limited to 'src/math/big/floatconv_test.go')
| -rw-r--r-- | src/math/big/floatconv_test.go | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/math/big/floatconv_test.go b/src/math/big/floatconv_test.go index 96c01eed81..9fc2b89fb9 100644 --- a/src/math/big/floatconv_test.go +++ b/src/math/big/floatconv_test.go @@ -125,12 +125,16 @@ func TestFloat64Format(t *testing.T) { {1, 'f', 0, "1"}, {-1, 'f', 0, "-1"}, + {0.001, 'e', 0, "1e-03"}, + {0.459, 'e', 0, "5e-01"}, {1.459, 'e', 0, "1e+00"}, {2.459, 'e', 1, "2.5e+00"}, {3.459, 'e', 2, "3.46e+00"}, {4.459, 'e', 3, "4.459e+00"}, {5.459, 'e', 4, "5.4590e+00"}, + {0.001, 'f', 0, "0"}, + {0.459, 'f', 0, "0"}, {1.459, 'f', 0, "1"}, {2.459, 'f', 1, "2.5"}, {3.459, 'f', 2, "3.46"}, @@ -145,8 +149,8 @@ func TestFloat64Format(t *testing.T) { {0, 'p', 0, "0"}, {math.Copysign(0, -1), 'p', 0, "-0"}, - {1024.0, 'p', 0, "0x.8p11"}, - {-1024.0, 'p', 0, "-0x.8p11"}, + {1024.0, 'p', 0, "0x.8p+11"}, + {-1024.0, 'p', 0, "-0x.8p+11"}, // all test cases below from strconv/ftoa_test.go {1, 'e', 5, "1.00000e+00"}, @@ -331,8 +335,8 @@ func TestFloatFormat(t *testing.T) { {"3e40", 100, 'g', 40, "3e+40"}, // make sure "stupid" exponents don't stall the machine - {"1e1000000", 64, 'p', 0, "0x.88b3a28a05eade3ap3321929"}, - {"1e1000000000", 64, 'p', 0, "0x.ecc5f45aa573d3p1538481529"}, + {"1e1000000", 64, 'p', 0, "0x.88b3a28a05eade3ap+3321929"}, + {"1e1000000000", 64, 'p', 0, "0x.ecc5f45aa573d3p+1538481529"}, {"1e-1000000", 64, 'p', 0, "0x.efb4542cc8ca418ap-3321928"}, {"1e-1000000000", 64, 'p', 0, "0x.8a64dd983a4c7dabp-1538481528"}, @@ -352,20 +356,21 @@ func TestFloatFormat(t *testing.T) { {"3.00", 350, 'b', 0, "1720123961992553633708115671476565205597423741876210842803191629540192157066363606052513914832594264915968p-348"}, {"3.000", 350, 'b', 0, "1720123961992553633708115671476565205597423741876210842803191629540192157066363606052513914832594264915968p-348"}, - {"3", 350, 'p', 0, "0x.cp2"}, - {"03", 350, 'p', 0, "0x.cp2"}, - {"3.", 350, 'p', 0, "0x.cp2"}, - {"3.0", 350, 'p', 0, "0x.cp2"}, - {"3.00", 350, 'p', 0, "0x.cp2"}, - {"3.000", 350, 'p', 0, "0x.cp2"}, + {"3", 350, 'p', 0, "0x.cp+2"}, + {"03", 350, 'p', 0, "0x.cp+2"}, + {"3.", 350, 'p', 0, "0x.cp+2"}, + {"3.0", 350, 'p', 0, "0x.cp+2"}, + {"3.00", 350, 'p', 0, "0x.cp+2"}, + {"3.000", 350, 'p', 0, "0x.cp+2"}, {"0", 64, 'p', 0, "0"}, {"-0", 64, 'p', 0, "-0"}, - {"1024.0", 64, 'p', 0, "0x.8p11"}, - {"-1024.0", 64, 'p', 0, "-0x.8p11"}, + {"1024.0", 64, 'p', 0, "0x.8p+11"}, + {"-1024.0", 64, 'p', 0, "-0x.8p+11"}, // unsupported format {"3.14", 64, 'x', 0, "%x"}, + {"-3.14", 64, 'x', 0, "%x"}, } { f, _, err := ParseFloat(test.x, 0, test.prec, ToNearestEven) if err != nil { |
