FAQ
LGTM

The part about "is 0.01" is not precisely correct. The numbers below are
the real ones. It doesn't matter because in a Go program 0.01 used in a
float64 context really means
0.01000000000000000020816681711721685132943093776702880859375, but it
will avoid confusion later if we are precise here.

Also, although I didn't note it below, I think it might help to use

panic(fmt.Sprintf("F=%.1000g, want %.1000g", F, F32))

because the default printer for float64s is not very precise and perhaps
not even very accurate.


https://codereview.appspot.com/6855053/diff/10001/test/fixedbugs/bug470.go
File test/fixedbugs/bug470.go (right):

https://codereview.appspot.com/6855053/diff/10001/test/fixedbugs/bug470.go#newcode11
test/fixedbugs/bug470.go:11: var F = float64(float32(0.01))
var F = float64(float32(0.01))

const (
F32 = 0.00999999977648258209228515625
F64 = 0.01000000000000000020816681711721685132943093776702880859375
)

https://codereview.appspot.com/6855053/diff/10001/test/fixedbugs/bug470.go#newcode14
test/fixedbugs/bug470.go:14: // 0.01 rounded to float32 then to float64
is 0.009999999776482582.
is F32.
next line
is F64.

https://codereview.appspot.com/6855053/diff/10001/test/fixedbugs/bug470.go#newcode16
test/fixedbugs/bug470.go:16: if F == 0.01 {
if F != F32 {
panic(F)
}

https://codereview.appspot.com/6855053/

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedNov 26, '12 at 3:37p
activeNov 26, '12 at 4:39p
posts2
users2
websitegolang.org

2 users in discussion

Iant: 1 post Rsc: 1 post

People

Translate

site design / logo © 2022 Grokbase