6
PhiMa
6y

Does anyone knows why in c++ floats range from numeric_limits<float>::lowest() to ::max() and ::min() is just the lowest positive value instead the actual minimum? This strange naming convention just costs me an hour of my life that I'm never getting back...

Comments
  • 3
    Good question. But the reference states that min() for floats when comparing to integral types may result in undefined behaviour and you should use lowest(). Lowest is guaranteed to return the lowest possible number. Where as min() also just returns FLT_MIN for floats which is the minimum normalized positive value of a float.

    Dont ask me why.
  • 3
    If I understand your question correctly, the same behaviour is observer in Java. MIN_FLOAT is the smallest value of float in bits. Which means all zeroed out (the sign bit is also zero here) which gives you the smallest positive number you can put into a memory using the IEEE standard. The naming isnt great with this one
Add Comment