32 位有符号整数如何表示负数? [英] How are negative numbers represented in 32-bit signed integer?
本文介绍了32 位有符号整数如何表示负数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
How are negative number represented in 32-bit signed integer? Is it two's or one's complement? or the last bit on the left is like a flag? For example: (-10)
解决方案
Most computers these days use two's complement for signed integers, but it can vary by hardware architecture, programming language, or other platform-specific issues.
For a two's-complement representation, the most-significant ("leftmost") bit is referred to as the sign bit, and it will be set for a negative integer and clear for a non-negative integer. However, it is more than just a "flag". See the Wikipedia article for more information.
这篇关于32 位有符号整数如何表示负数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文