Obtain minimum NEGATIVE float value in C++

前端 未结 3 1783
猫巷女王i
猫巷女王i 2021-02-05 03:04

I was looking at std::numeric_limits::min/max() but it appears \'min()\' returns the smallest absolute value, not the lowest value. Is it safe

3条回答
  •  我寻月下人不归
    2021-02-05 03:34

    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::max() as you suspected.

提交回复
热议问题