Is it possible to differentiate between 0 and -0?

前端 未结 7 1431
鱼传尺愫
鱼传尺愫 2021-01-31 07:11

I know that the integer values 0 and -0 are essentially the same. But, I am wondering if it is possible to differentiate between them.

For exam

相关标签:
7条回答
  • 2021-01-31 07:28

    To simplify i found it easier to visualize.

    Type int(_32) is stored with 32 bits. 32 bits means 2^32 = 4294967296 unique values. Thus :

    unsigned int data range is 0 to 4,294,967,295

    In case of negative values it depends on how they are stored. In case

    • Two's complement –2,147,483,648 to 2,147,483,647
    • One's complement –2,147,483,647 to 2,147,483,647

    In case of One's complement value -0 exists.

    0 讨论(0)
提交回复
热议问题