3.2 Floating-Point Numbers
Go provides two sizes of floating-point numbers, float32 and
float64.
Their arithmetic properties are governed by the IEEE 754 standard
implemented by all modern CPUs.
Values of these numeric types range from tiny to huge.
The limits of floating-point values can be found in the math
package.
The constant math.MaxFloat32, the largest float32, is
about 3.4e38, and math.MaxFloat64 is about 1.8e308.
The smallest
positive values are near 1.4e-45 and 4.9e-324, respectively.
A float32 provides approximately six decimal digits of precision, whereas
a float64 provides about 15 digits; float64 should be preferred for
most purposes because float32 computations accumulate error rapidly unless one is quite careful, and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access