二进制补码形式 [英] Two's complement binary form

查看:111
本文介绍了二进制补码形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在TC ++编译器中, 5 的二进制表示形式是(00000000000000101). 我知道负数存储为2的补数,因此二进制中的 -5 (111111111111011).最高有效位(符号位)为1,表示它是负数.

In a TC++ compiler, the binary representation of 5 is (00000000000000101). I know that negative numbers are stored as 2's complement, thus -5 in binary is (111111111111011). The most significant bit (sign bit) is 1 which tells that it is a negative number.

那么编译器如何知道它是 -5 ?如果我们将(111111111111011)上面给出的二进制值解释为无符号数字,结果会完全不同吗?

So how does the compiler know that it is -5? If we interpret the binary value given above (111111111111011) as an unsigned number, it will turn out completely different?

还有,为什么1表示 5 -6(1111111111111010)?

Also, why is the 1's compliment of 5 -6 (1111111111111010)?

推荐答案

编译器不知道.如果将-5强制转换为unsigned int,则会得到32763.

The compiler doesn't know. If you cast -5 to unsigned int you'll get 32763.

这篇关于二进制补码形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆