diff options
| author | Robert Griesemer <gri@golang.org> | 2015-05-22 13:58:03 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2015-05-22 23:12:51 +0000 |
| commit | 2df1ccdbc6aac9e570e985437d741d723cb3497c (patch) | |
| tree | d502df4099b123bcfbdfef51a11d4fe774dae984 /src/math/big/floatconv_test.go | |
| parent | 22e4b8167f14bdd33738cfdc21c3396b2341f8fd (diff) | |
| download | go-2df1ccdbc6aac9e570e985437d741d723cb3497c.tar.xz | |
math/big: Always print exponent sign when using 'p' exponent for Floats.
Float.Format supports the 'b' and 'p' format, both of which print
a binary ('p') exponent. The 'b' format always printed a sign ('+'
or '-') for the exponent; the 'p' format only printed a negative
sign for the exponent. This change makes the two consistent. It
also makes the 'p' format easier to read if the exponent is >= 0.
Also:
- Comments added elsewhere.
Change-Id: Ifd2e01bdafb3043345972ca22a90248d055bd29b
Reviewed-on: https://go-review.googlesource.com/10359
Reviewed-by: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src/math/big/floatconv_test.go')
| -rw-r--r-- | src/math/big/floatconv_test.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/math/big/floatconv_test.go b/src/math/big/floatconv_test.go index 96c01eed81..6ba15754e5 100644 --- a/src/math/big/floatconv_test.go +++ b/src/math/big/floatconv_test.go @@ -145,8 +145,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 +331,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,17 +352,17 @@ 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"}, |
