aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-04-29 15:01:29 -0700
committerRobert Griesemer <gri@golang.org>2021-04-30 00:13:38 +0000
commit3498027329a32c77315754054d1591e06349db59 (patch)
treebcc30130da2e8903014c18df34702ee4e567e5f6 /api
parent02ab8d1a1dc82ce019969221313bfa28911f54a1 (diff)
downloadgo-3498027329a32c77315754054d1591e06349db59.tar.gz
go-3498027329a32c77315754054d1591e06349db59.zip
math: increase precision of math.SmallestNonzeroFloat64
The original value was rounded too early, which lead to the surprising behavior that float64(math.SmallestNonzeroFloat64 / 2) wasn't 0. That is, the exact compile-time computation of math.SmallestNonzeroFloat64 / 2 resulted in a value that was rounded up when converting to float64. To address this, added 3 more digits to the mantissa, ending in a 0. While at it, also slightly increased the precision of MaxFloat64 to end in a 0. Computed exact values via https://play.golang.org/p/yt4KTpIx_wP. Added a test to verify expected behavior. In contrast to the other (irrational) constants, expanding these extreme values to more digits is unlikely to be important as they are not going to appear in numeric computations except for tests verifying their correctness (as is the case here). Re-enabled a disabled test in go/types and types2. Updates #44057. Fixes #44058. Change-Id: I8f363155e02331354e929beabe993c8d8de75646 Reviewed-on: https://go-review.googlesource.com/c/go/+/315170 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'api')
-rw-r--r--api/except.txt2
1 files changed, 2 insertions, 0 deletions
diff --git a/api/except.txt b/api/except.txt
index 6f6f839ba6..f5a7aa854e 100644
--- a/api/except.txt
+++ b/api/except.txt
@@ -1,4 +1,6 @@
pkg encoding/json, method (*RawMessage) MarshalJSON() ([]uint8, error)
+pkg math, const MaxFloat64 = 1.79769e+308 // 179769313486231570814527423731704356798100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+pkg math, const SmallestNonzeroFloat64 = 4.94066e-324 // 4940656458412465441765687928682213723651/1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
pkg math/big, const MaxBase = 36
pkg math/big, type Word uintptr
pkg net, func ListenUnixgram(string, *UnixAddr) (*UDPConn, error)