Why the absolute value of the max negative integer -2147483648 is still -2147483648?

前端 未结 5 1995
悲哀的现实
悲哀的现实 2020-12-03 05:14

The result of abs(-2147483648) is -2147483648, isn\'t it? it seems unacceptable.

printf(\"abs(-2147483648): %d\\n\", abs(-2147483648));

out

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 05:25

    Since 2147483648 is greater than INT_MAX on your implementation, then abs(-2147483648) is undefined.

提交回复
热议问题