]> Cypherpunks repositories - gostls13.git/commitdiff
floating-point limits and equations
authorRuss Cox <rsc@golang.org>
Tue, 28 Jul 2009 21:50:50 +0000 (14:50 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 28 Jul 2009 21:50:50 +0000 (14:50 -0700)
R=r
DELTA=13  (8 added, 2 deleted, 3 changed)
OCL=32291
CL=32322

src/pkg/math/const.go

index 837fe6bc95aa3532058d01252e8759f889a7c8c3..13ecbcb08ac4b272d147518e073b0d9f6dd5333b 100644 (file)
@@ -23,13 +23,19 @@ const (
        Log10E  = 1/Ln10;
 )
 
-// Limit values
+// Floating-point limit values.
+// Max is the largest finite value representable by the type.
+// Min is the smallest nonzero value representable by the type.
 const (
-       MaxFloat32      = 3.40282346638528860e+38;
-       MinFloat32      = 1.40129846432481707e-45;
-       MaxFloat64      = 1.7976931348623157e+308;
-       MinFloat64      = 5.0e-324;
+       MaxFloat32 = 3.40282346638528859811704183484516925440e+38;      /* 2^127 * (2^24 - 1) / 2^23 */
+       MinFloat32 = 1.401298464324817070923729583289916131280e-45;     /* 1 / 2^(127 - 1 + 23) */
 
+       MaxFloat64 = 1.797693134862315708145274237317043567981e+308;    /* 2^1023 * (2^53 - 1) / 2^52 */
+       MinFloat64 = 4.940656458412465441765687928682213723651e-324;    /* 1 / 2^(1023 - 1 + 52) */
+)
+
+// Integer limit values.
+const (
        MaxInt8 = 1<<7 - 1;
        MinInt8 = -1<<7;
        MaxInt16 = 1<<15 - 1;