4 ms·
Fun fact, related: Julia has a function to give you the next greater floating point number for any floating point number, nextfloat(x), and it is basically imp
by FabHK 3y ago
Fun fact, related:
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/3120989f39bb7ef7863c4aab8ab1227cf71eec66/base/float.jl#L800 https://github.com/JuliaLang/julia/blob/3120989f39bb7ef7863c...
- renonce 3y agoPositive floating numbers can indeed be compared by their binary representation. The fact that incrementing the number by one gives you the next floating point number is a trivial corollary.