在C ++中获取最小NEGATIVE浮点值 [英] Obtain minimum NEGATIVE float value in C++
问题描述
我看着 std :: numeric_limits< float> :: min / max()
,但它看起来'min()'返回最小的绝对值, 最低值。是否安全使用
-std :: numeric_limits< float> :: max()
IEEE 754浮点数使用一个符号位进行签名(而不是类似于下面这样的操作):
二进制补码),所以如果你确定你的编译器/平台使用该表示(非常常见),那么你可以使用 -std :: numeric_limits< float> :: max()
您怀疑。
I was looking at std::numeric_limits<float>::min/max()
but it appears 'min()' returns the smallest absolute value, not the lowest value. Is it safe to use
-std::numeric_limits<float>::max()
, i.e is float symmetric in min/max limits?
IEEE 754 floating point numbers use a sign bit for signed-ness (rather than something like twos complement), so if you're sure that your compiler/platform uses that representation (very common) then you can use -std::numeric_limits<float>::max()
as you suspected.
这篇关于在C ++中获取最小NEGATIVE浮点值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!