You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
float32(Rat.Float64(x)) is not the same as Rat.Float32(x) in general (adjusted for
correct arguments, etc.):
package main
import (
"fmt"
"math/big"
)
func main() {
const x = 340282356779733661637539395458142568447
fmt.Println(float64(x), float32(x))
z, ok := new(big.Rat).SetString("340282356779733661637539395458142568447")
if !ok {
panic("SetString failed")
}
t, _ := z.Float64()
fmt.Println(t, float32(t))
}
produces:
3.4028235677973366e+38 3.4028235e+38
3.4028235677973366e+38 +Inf
i.e., we need a Rat.Float32 implementation with correct rounding for 32bit floats.
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: