4 ms·
A Long is 64 bits. An Int is 32 bits. A Float is 32 bits (8 bits exponent, 23 fraction, 1 sign). I don't see how anyone could expect a Float to have enough bits
by noelwelsh 13y ago
A Long is 64 bits. An Int is 32 bits. A Float is 32 bits (8 bits exponent, 23 fraction, 1 sign). I don't see how anyone could expect a Float to have enough bits to represent the difference. The only different behaviour I can envisage is an error, but it is standard practice to disable these for performance reasons.
- bad_user 13y agoA Float on the other hand, by definition, is only an approximation. You can use fixed-point numbers, but they are either too slow or lack the required precision. > val x: BigDecimal = Long.MaxValue Problem solved. Or is it?