]> Cypherpunks repositories - gostls13.git/commitdiff
be more precise in ftoa_test.
authorRuss Cox <rsc@golang.org>
Tue, 2 Dec 2008 00:03:09 +0000 (16:03 -0800)
committerRuss Cox <rsc@golang.org>
Tue, 2 Dec 2008 00:03:09 +0000 (16:03 -0800)
R=ken
OCL=20173
CL=20173

src/lib/strconv/ftoa_test.go

index 643abb0dd47f9f4d0a5bd0bf3b129d3b8b6a17cb..6b90ff2f320465a3d8966eb39fa0d85b33a97bed 100644 (file)
@@ -18,6 +18,11 @@ type Test struct {
 
 func fdiv(a, b float64) float64 { return a / b }       // keep compiler in the dark
 
+const (
+       Below1e23 = 99999999999999974834176;
+       Above1e23 = 100000000000000008388608;
+)
+
 // TODO: Should be able to call this tests but it conflicts with testatof.go
 var ftests = []Test {
        Test{ 1, 'e', 5, "1.00000e+00" },
@@ -61,21 +66,21 @@ var ftests = []Test {
        Test{ 1e23, 'f', -1, "100000000000000000000000" },
        Test{ 1e23, 'g', -1, "1e+23" },
 
-       Test{ 1e23-8.5e6, 'e', 17, "9.99999999999999748e+22" },
-       Test{ 1e23-8.5e6, 'f', 17, "99999999999999974834176.00000000000000000" },
-       Test{ 1e23-8.5e6, 'g', 17, "9.9999999999999975e+22" },
+       Test{ Below1e23, 'e', 17, "9.99999999999999748e+22" },
+       Test{ Below1e23, 'f', 17, "99999999999999974834176.00000000000000000" },
+       Test{ Below1e23, 'g', 17, "9.9999999999999975e+22" },
 
-       Test{ 1e23-8.5e6, 'e', -1, "9.999999999999997e+22" },
-       Test{ 1e23-8.5e6, 'f', -1, "99999999999999970000000" },
-       Test{ 1e23-8.5e6, 'g', -1, "9.999999999999997e+22" },
+       Test{ Below1e23, 'e', -1, "9.999999999999997e+22" },
+       Test{ Below1e23, 'f', -1, "99999999999999970000000" },
+       Test{ Below1e23, 'g', -1, "9.999999999999997e+22" },
 
-       Test{ 1e23+8.5e6, 'e', 17, "1.00000000000000008e+23" },
-       Test{ 1e23+8.5e6, 'f', 17, "100000000000000008388608.00000000000000000" },
-       Test{ 1e23+8.5e6, 'g', 17, "1.0000000000000001e+23" },
+       Test{ Above1e23, 'e', 17, "1.00000000000000008e+23" },
+       Test{ Above1e23, 'f', 17, "100000000000000008388608.00000000000000000" },
+       Test{ Above1e23, 'g', 17, "1.0000000000000001e+23" },
 
-       Test{ 1e23+8.5e6, 'e', -1, "1.0000000000000001e+23" },
-       Test{ 1e23+8.5e6, 'f', -1, "100000000000000010000000" },
-       Test{ 1e23+8.5e6, 'g', -1, "1.0000000000000001e+23" },
+       Test{ Above1e23, 'e', -1, "1.0000000000000001e+23" },
+       Test{ Above1e23, 'f', -1, "100000000000000010000000" },
+       Test{ Above1e23, 'g', -1, "1.0000000000000001e+23" },
 
        Test{ fdiv(5e-304, 1e20), 'g', -1, "5e-324" },
        Test{ fdiv(-5e-304, 1e20), 'g', -1, "-5e-324" },