Does float have a negative zero? (-0f)

后端 未结 10 729
离开以前
离开以前 2020-11-28 09:36

IEEE floating point numbers have a bit assigned to indicate the sign, which means you can technically have different binary representations of zero (+0 and -0). Is there an

10条回答
  •  爱一瞬间的悲伤
    2020-11-28 10:34

    Yes, float does have a negative zero, but no, you don't have to worry about this when comparing floating-point values.

    Floating-point arithmetic is defined to work correctly on special cases.

提交回复
热议问题