i need to obtain float NaN and infinity, but i can't use such constructions
0. / 0.
1. / 0.
because it cause compile time
error C2124: divide or mod by zero
EDIT, it is cool to have answers for where i can get this numbers (+1 for every), but is it possible to divide by zero?
You can simply return a NaN or an infinity, for example:
return std::numeric_limits<float>::quiet_NaN();
or
return std::numeric_limits<float>::infinity();
See std::numeric_limits
, from header <limits>
.
Use std::numeric_limits::infinity() and std::numeric_limits::quiet_NaN() or std::numeric_limits::signaling_NaN() from <limits>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With