top | item 22572937

(no title)

snek | 6 years ago

> and did you know that IEEE-754 floating point can represent a "negative zero" that you can use for an error code in functions that return float or double?

I am begging, please never ever do this. NaN literally exists for this reason. NaN even allows you to encode additional error context and details into the value.

discuss

order

saagarjha|6 years ago

+DBL_MAX. Negative zero is an entirely valid, if rare, result of certain computations.

pwdisswordfish2|6 years ago

IEEE 754 has infinities as well, no need to constrain yourself to DBL_MAX :)