Say I have two Python floats a
and b
, is there an easy way to find out how many representable real numbers are between the two in IEEE-754 representati
AFAIK, IEEE754 floats have an interesting property. If you have float f, then
(*(int*)&f + 1)
under certain conditions, is the next representable floating point number. So for floats a and b
*(int*)&a - *(int*)&b
Will give you the amount of floating point numbers between those numbers.
See http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm for more information.