Skip to content

Commit 7b768d4

Browse files
committed
math: replace float32/64 extrema with exact expressions
Follow-up on https://golang.org/cl/315170. Updates #44057. Updates #44058. Change-Id: I0b071e8ee7a1c97aae2436945cc9583cde3b40b0 Reviewed-on: https://go-review.googlesource.com/c/go/+/315969 Trust: Robert Griesemer <[email protected]> Trust: Emmanuel Odeke <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: Russ Cox <[email protected]>
1 parent be1da9c commit 7b768d4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

api/except.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pkg encoding/json, method (*RawMessage) MarshalJSON() ([]uint8, error)
22
pkg math, const MaxFloat64 = 1.79769e+308 // 179769313486231570814527423731704356798100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3+
pkg math, const SmallestNonzeroFloat32 = 1.4013e-45 // 17516230804060213386546619791123951641/12500000000000000000000000000000000000000000000000000000000000000000000000000000000
34
pkg math, const SmallestNonzeroFloat64 = 4.94066e-324 // 4940656458412465441765687928682213723651/1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
45
pkg math/big, const MaxBase = 36
56
pkg math/big, type Word uintptr

src/math/const.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ const (
2828
// Max is the largest finite value representable by the type.
2929
// SmallestNonzero is the smallest positive, non-zero value representable by the type.
3030
const (
31-
MaxFloat32 = 3.40282346638528859811704183484516925440e+38 // 2**127 * (2**24 - 1) / 2**23
32-
SmallestNonzeroFloat32 = 1.401298464324817070923729583289916131280e-45 // 1 / 2**(127 - 1 + 23)
31+
MaxFloat32 = 0x1p127 * (1 + (1 - 0x1p-23)) // 3.40282346638528859811704183484516925440e+38
32+
SmallestNonzeroFloat32 = 0x1p-126 * 0x1p-23 // 1.401298464324817070923729583289916131280e-45
3333

34-
MaxFloat64 = 1.79769313486231570814527423731704356798070e+308 // 2**1023 * (2**53 - 1) / 2**52
35-
SmallestNonzeroFloat64 = 4.9406564584124654417656879286822137236505980e-324 // 1 / 2**(1023 - 1 + 52)
34+
MaxFloat64 = 0x1p1023 * (1 + (1 - 0x1p-52)) // 1.79769313486231570814527423731704356798070e+308
35+
SmallestNonzeroFloat64 = 0x1p-1022 * 0x1p-52 // 4.9406564584124654417656879286822137236505980e-324
3636
)
3737

3838
// Integer limit values.

0 commit comments

Comments
 (0)