I need to get float NaN and infinity, but I cannot use such constructs
0. / 0. 1. / 0.
because it causes compilation time
error C2124: division or mod by zero
EDIT, great to have answers where I can get these numbers (+1 for each), but is it possible to divide by zero?
You can simply return NaN or infinity, for example:
return std::numeric_limits<float>::quiet_NaN();
or
return std::numeric_limits<float>::infinity();
See std::numeric_limits , from the <limits> header.
std::numeric_limits
<limits>
Use std :: numeric_limits :: infinity () and std :: numeric_limits :: quiet_NaN () or std :: numeric_limits :: signaling_NaN () from <limits> .