4 ms·
> When you convert from int to float, the number stays accurate to however many digits The point of the article is that this "however many digits" actually imp
by titzer 1y ago
> When you convert from int to float, the number stays accurate to however many digits
The point of the article is that this "however many digits" actually implies rounding many numbers that aren't that big. A single precision (i.e. 32-bit) float cannot exactly represent some 32-bit integers. For example 1_234_567_891f is actually rounded to 1_234_567_936. This is because there are only 23 bits of fraction available (https://en.wikipedia.org/wiki/Single-precision_floating-point_format https://en.wikipedia.org/wiki/Single-precision_floating-poin...).