Why the absolute value of the max negative integer -2147483648 is still -2147483648?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: The result of abs(-2147483648) is -2147483648, isn't it? it seems unacceptable. printf ( "abs(-2147483648): %d\n" , abs (- 2147483648 )); output: abs (- 2147483648 ): - 2147483648 回答1: The standard says about abs() : The abs , labs , and llabs functions compute the absolute value of an integer j . If the result cannot be represented, the behavior is undefined. And the result indeed cannot be represented because the 2's complement representation of signed integers isn't symmetric. Think about it... If you have 32 bits in an int ,