While converting a float32 number to float64 precision is being lost in Go. For example converting 359.9 to float64 produces 359.8999938964844. If float32 can be stored precisely why is float64 losing precision?
Sample code:
package main
import (
"fmt"
)
func main() {
var a float32 = 359.9
fmt.Println(a)
fmt.Println(float64(a))
}
Try it on Playground
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With