Skip to content

Commit

Permalink
test/float_lit2: fix expressions in comment
Browse files Browse the repository at this point in the history
The change corrects the values of the largest float32 value (f1) and the
value of the halfway point between f1 and the next, overflow value (f2).

Fixes #17012

Change-Id: Idaf9997b69d61fafbffdb980d751c9857732e14d
Reviewed-on: https://go-review.googlesource.com/29171
Reviewed-by: Robert Griesemer <gri@golang.org>
  • Loading branch information
Jan Mercl authored and griesemer committed Sep 14, 2016
1 parent 7f583a4 commit 2e67514
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/float_lit2.go
Expand Up @@ -13,12 +13,12 @@ import (
"math"
)

// The largest exact float32 is f₁ = (1+(1-2²³))×2¹²⁷ = (1-2²⁴)×2¹² = 2¹²⁸ - 2¹⁰⁴.
// The largest exact float32 is f₁ = (1+1-1/2²³)×2¹²⁷ = (2-2⁻²³)×2¹² = 2¹²⁸ - 2¹⁰⁴.
// The next float32 would be f₂ = (1+1)×2¹²⁷ = 1×2¹²⁸, except that exponent is out of range.
// Float32 conversion rounds to the nearest float32, rounding to even mantissa:
// between f₁ and f₂, values closer to f₁ round to f₁ and values closer to f₂ are rejected as out of range.
// f₁ is an odd mantissa, so the halfway point (f₁+f₂)/2 rounds to f₂ and is rejected.
// The halfway point is (f₁+f₂)/2 = 2¹²⁸ - 2¹⁰.
// The halfway point is (f₁+f₂)/2 = 2¹²⁸ - 2¹⁰³.
//
// The same is true of float64, with different constants: s/24/53/ and s/128/1024/.

Expand Down

0 comments on commit 2e67514

Please sign in to comment.