Why does integer representation of a floating point approximate its logarithm?
stackoverflow.com
stackoverflow.com
From the question
"Why I am asking
I am writing a history of the Fast Inverse Square Root, information about which is collected at 0x5f37642f.com. Part of investigating this as a historian means asking questions like this from the community. I do not have the expertise to distill, by myself, much of this because I am not a mathematician or a computer scientist."
"Why is an IEEE 754 positive [normal] number interpreted as an integer a piecewise linear approximation of its logarithm?" -> "Because the bit pattern for it will have an exponent followed by a mantissa, where the exponent by definition is a very rough approximation of the logarithm, and where the mantissa can be interpreted as a linear interpolation between the exponent and the next exponent, thus the two pieces as the "piecewise" (exponent) and "linear" (mantissa) approximation of the number's logarithm."
The only remaining bits of interest is the bias of the exponent and the assumed-1 leading digit of the mantissa being left out. The latter is a compression technique (why wastefully include a bit that's always set or always reset?) that happens to help here (avoiding having to shift the mantissa bits by one). The former is easy enough to deal with.
Julia has a function to give you the next greater floating point number for any floating point number, nextfloat(x), and it is basically implemented by casting x to an integer, adding 1, and casting it back.
https://github.com/JuliaLang/julia/blob/3120989f39bb7ef7863c...
A float is ...-exp-int
A log is exp-int -> int(Not every question needs to be this long--this one's length seems to be because the asker is more a historian than a mathematician--but length and such sections--graphs, links etc--are one way it gets signaled that you really have put effort into the question.)
So when asking (~80 questions asked so far across SE sites, only 8 on Stack Overflow), I try to put effort into it (and show it), but ultimately still just treat each question as a gamble and if it doesn't "work out" (question got few/zero/negative votes, or no useful answers) it's no big deal (just lost a turn, try again next time… at least I learned something about what sorts of questions work well on this particular site, and got an opportunity to state my question as clearly as I could, which is often the most useful part of the process). But I can see how people who approach asking questions on StackOverflow from a mindset of "I need help and hope to get it here" can easily get frustrated.