简体   繁体   English

将双精度舍入到最近的非次正规表示

[英]Round double to nearest non subnormal representation

In C++ there are (sometimes) subnormal doubles that are finite, not nan and not zero.在 C++ 中,有(有时)次正规双精度数是有限的,不是nan也不是零。

How can I round them to nearest non subnormal double representation?如何将它们四舍五入到最接近的非次正规双表示?

For example: std::isnormal(DBL_MIN/2.0) = false例如: std::isnormal(DBL_MIN/2.0) = false

All subnormal double magnitudes are between 0 and DBL_MIN .所有次正常双倍幅度都在 0 和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 .如果某个值小于DBL_MIN ,则根据将其与DBL_MIN/2进行比较,将其四舍五入为其中之一。 (To match usual IEEE-754 rounding behavior, DBL_MIN/2 itself should be rounded to 0.) (为了匹配通常的 IEEE-754 舍入行为, DBL_MIN/2本身应该舍入为 0。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM