Uses for negative zero floating point value?

前端 未结 5 1379
天命终不由人
天命终不由人 2020-12-03 04:53

Consider the following C++ code:

double someZero = 0;
std::cout << 0 - someZero << \'\\n\';   // prints 0
std::cout << -someZero << s         


        
5条回答
  •  旧时难觅i
    2020-12-03 05:37

    In addition Signed Zero Good For :

    The zeroes can be considered as a variant of the extended real number line such that 1/−0 = −∞ and 1/+0 = +∞, division by zero is only undefined for ±0/±0.

    Negatively signed zero echoes the mathematical analysis concept of approaching 0 from below as a one-sided limit, which may be denoted by x → 0−, x → 0−, or x → ↑0. The notation "−0" may be used informally to denote a small negative number that has been rounded to zero. The concept of negative zero also has some theoretical applications in statistical mechanics and other disciplines

提交回复
热议问题