FP32, or Go's float32, stores floating-point values in 4 bytes under IEEE-754. It offers approximately six to seven reliable decimal significant digits, so values beyond that range may change during representation or arithmetic. section 6.2.1
Use FP32 with these limitations in mind:
- Expect most decimal fractions to be approximate; values such as 0.625 are exactly representable, but many others are not. section 6.2.1
- Treat additions and subtractions involving very different magnitudes cautiously: subtracting 1 from float32(100_000_000) leaves the stored value unchanged. section 6.2.3
- Avoid == for floating-point results; compare values within an appropriate precision range instead. section 6.2.3
Precision loss in practice
Formatting float32(123_456_789) with %.f produces 123456792, while formatting float32(0.0123456789) with %.10f produces 0.0123456791. The first reliable digits remain useful; later digits should not be trusted. section 6.2.1
fmt.Printf("%.8f", float32(1)/float32(41)*float32(41))
Evaluate a float32 division and multiplication chain while inspecting its formatted result. section 6.2.1





