Why is abs(0x80000000) == 0x80000000?

前端 未结 9 1409
心在旅途
心在旅途 2021-02-07 02:51

I just started reading Hacker\'s Delight and it defines abs(-231) as -231. Why is that?

I tried printf(\"%x\", abs(0x80000000)) on a f

9条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-07 03:20

    For a 32bit datatype there is no expression of +2^31, because the biggest number is 2^31-1 ... read more about the two's complement ...

提交回复
热议问题