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>
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.