In C++ there are (sometimes) subnormal doubles that are finite, not nan
and not zero.
How can I round them to nearest non subnormal double representation?
For example: std::isnormal(DBL_MIN/2.0) = false
All subnormal double magnitudes are between 0 and DBL_MIN
. If a value is less than DBL_MIN
, just round it to one of those, based on comparing it to DBL_MIN/2
. (To match usual IEEE-754 rounding behavior, DBL_MIN/2
itself should be rounded to 0.)
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.