3 ms·
I think the parent comment is saying it's confusing to associate floats with decimals like 0.123. Instead it's more accurate to think of them as being in scien
by ants_everywhere 1y ago
I think the parent comment is saying it's confusing to associate floats with decimals like 0.123.
Instead it's more accurate to think of them as being in scientific notation like 1.23E-1.
In this notation it's clearer that they're sparsely populated because some of the 32 bits encode the exponent, which grows and shrinks very quickly.
But yes rationals are reals. It's clear that you can't represent, say, all digits of pi in 32 bits, so the parent comment was not saying that 32 bit floats are all of the reals.
- perching_aix 1y agoYeah, that's fair. Personally, I like to think of them as a log compressed way of expressing fractional values, like how one would record in log with a camera to capture rich dark scenes while maintaining highlight detail. I think the bigger problem with floats is that the types and operations around them are pretty loose and permissive, although maybe I just don't appreciate how well the usual compromises work. Was pretty cool to dig into arbitrary precision math libraries a while back though, found some fun stuff in there. Also found out that my Android phone's Calculator app is not calculating in base 10, unlike Windows' Calculator...
- adastra22 1y agoWhich is what scientific notation is.