# <Principle Of Computer Organization>学习笔记——原码、反码、补码

Lierba · · 847 次点击 · · 开始浏览

``````example-1:
若：X = 0.0110
则：[X]原 = X = 0.0110

若：X = -0.0110
则：[X]原 = 1 - X
= 1 - (-0.0110)
= 1 + 0.0110
= 1.0110
``````

``````example-2:
若：X = 1101
则：[X]原 = X = 01101

若：X = -1101
则：[X]原 = 2^n - X
= 2^4 - (-1101)
= 10000 + 1101
= 11101
``````

``````[+0]原 = 00000
[-0]原 = 10000
``````

1.模和同余

（1）将分针倒着旋转两圈(即时钟倒拨两个小时)，8 - 2 = 6(做减法)
（2）将分针正着旋转10圈(即时钟正拨10小时)，8 + 10 = 6(mod 12)(做加法) 此时，8 - 2 = 8 + 10(mod 12)

``````example-3:
9 - 5 = 9 + (-5)
= 9 + (12 - 5)
= 9 + 7
= 4(mod 12)

example-4：
65 - 25 = 65 + (-25)
= 65 + (100 -25)
= 65 + 75
= 40(mod 100)
``````

2.补码表示

``````example-5:
若：X = 0.0110
则：[X]补 = X = 0.0110

若：X = -0.0110
则：[X]补 = 2 + X
= 2 + (-0.0110)
= 10 - 0.0110
= 1.1010
``````

``````example-6:
若：X = 1101;
则：[X]补 = X = 01101;

若：X = -1101;
则：[X]补 = 2^(n+1) + X
= 2^5 + (-1101)
= 100000 - 1101
= 10011
``````

``````[+0]补 = [-0]补 = 0000
``````
3.由真值、原码转换为补码

``````example-7:
若：[X]原 = 1.1110011000
则：[X]补 = 1.000110***1000***(符号位和斜体部分不变，其他位取反)
``````

``````example-8:
若：X = -0.1010001010
则：[X]补 = 1.0101110110

``````

``````example-9:
若：X = 0.0110
则：[X]反 = 0.0110

若：X = -0.0110
则：[X]反 = (2 - 2^-n) + X
= (2 - 2^-4) + (-0.0110)
= 1.1111 + (-0.0110)
= 1.1111 - 0.0110
= 1.1001
``````

``````example-10:
若：X = 1101
则：[X]反 = 01101

若：X = -1101
则：[X]反 = (2^(n+1) - 1) + X
= (2^5 - 1) + (-1101)
= 11111 - 1101
= 10010
``````

``````[+0]反 = 00000
[-0]反 = 11111

``````

（1）对于正数它们都等于真值本身，而对于负数各有不同的表示
（2）最高位都是表示符号位，补码和反码的符号位可作为数值位的一部分看待，和数值位一起参加运算；但原码的符号位不允许和数值位同等看待，必须分开进行处理
（3）对于真值0，原码和反码各有两种不同的表示形式，而反码只有唯一的一种表示形式
（4）原码、反码表示的正、负数范围相对于零来说是对称的；但补码负数表示范围较正数范围宽，能多表示一个最负的数(绝对值最大的负数)，其值等于-2^n(纯整数)或-1(纯小数)

0 回复

• 请尽量让自己的回复能够对别人有帮助
• 支持 Markdown 格式, **粗体**、~~删除线~~、``单行代码``
• 支持 @ 本站用户；支持表情（输入 : 提示），见 Emoji cheat sheet
• 图片支持拖拽、截图粘贴等方式上传

``````example-1:
若：X = 0.0110
则：[X]原 = X = 0.0110

若：X = -0.0110
则：[X]原 = 1 - X
= 1 - (-0.0110)
= 1 + 0.0110
= 1.0110
``````

``````example-2:
若：X = 1101
则：[X]原 = X = 01101

若：X = -1101
则：[X]原 = 2^n - X
= 2^4 - (-1101)
= 10000 + 1101
= 11101
``````

``````[+0]原 = 00000
[-0]原 = 10000
``````

1.模和同余

（1）将分针倒着旋转两圈(即时钟倒拨两个小时)，8 - 2 = 6(做减法)
（2）将分针正着旋转10圈(即时钟正拨10小时)，8 + 10 = 6(mod 12)(做加法) 此时，8 - 2 = 8 + 10(mod 12)

``````example-3:
9 - 5 = 9 + (-5)
= 9 + (12 - 5)
= 9 + 7
= 4(mod 12)

example-4：
65 - 25 = 65 + (-25)
= 65 + (100 -25)
= 65 + 75
= 40(mod 100)
``````

2.补码表示

``````example-5:
若：X = 0.0110
则：[X]补 = X = 0.0110

若：X = -0.0110
则：[X]补 = 2 + X
= 2 + (-0.0110)
= 10 - 0.0110
= 1.1010
``````

``````example-6:
若：X = 1101;
则：[X]补 = X = 01101;

若：X = -1101;
则：[X]补 = 2^(n+1) + X
= 2^5 + (-1101)
= 100000 - 1101
= 10011
``````

``````[+0]补 = [-0]补 = 0000
``````
3.由真值、原码转换为补码

``````example-7:
若：[X]原 = 1.1110011000
则：[X]补 = 1.000110***1000***(符号位和斜体部分不变，其他位取反)
``````

``````example-8:
若：X = -0.1010001010
则：[X]补 = 1.0101110110

``````

``````example-9:
若：X = 0.0110
则：[X]反 = 0.0110

若：X = -0.0110
则：[X]反 = (2 - 2^-n) + X
= (2 - 2^-4) + (-0.0110)
= 1.1111 + (-0.0110)
= 1.1111 - 0.0110
= 1.1001
``````

``````example-10:
若：X = 1101
则：[X]反 = 01101

若：X = -1101
则：[X]反 = (2^(n+1) - 1) + X
= (2^5 - 1) + (-1101)
= 11111 - 1101
= 10010
``````

``````[+0]反 = 00000
[-0]反 = 11111

``````

（1）对于正数它们都等于真值本身，而对于负数各有不同的表示
（2）最高位都是表示符号位，补码和反码的符号位可作为数值位的一部分看待，和数值位一起参加运算；但原码的符号位不允许和数值位同等看待，必须分开进行处理
（3）对于真值0，原码和反码各有两种不同的表示形式，而反码只有唯一的一种表示形式
（4）原码、反码表示的正、负数范围相对于零来说是对称的；但补码负数表示范围较正数范围宽，能多表示一个最负的数(绝对值最大的负数)，其值等于-2^n(纯整数)或-1(纯小数)