Hacker News new | ask | show | jobs
by snek 2290 days 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.

1 comments

+DBL_MAX. Negative zero is an entirely valid, if rare, result of certain computations.
IEEE 754 has infinities as well, no need to constrain yourself to DBL_MAX :)