当前位置:网站首页>Three expressions of integers and their storage in memory

Three expressions of integers and their storage in memory

2022-06-11 07:43:00 Fried tomatoes 110

Integers are stored in memory as complements

Integers have 3 A binary representation : Original code 、 Inverse and complement . Integers are stored in memory Complement code . Next, let me talk about the original code 、 What are the forms of inverse code and complement code .

For positive numbers , Its original code 、 The inverse and complement are the same .

integer , stay 32 It's a bit of a platform 4 Bytes ,32 A bit

Positive integer 5, Its original code 、 Inverse code 、 The complement is the same , as follows :

Original code :0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1

Inverse code :0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1

Complement code :0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1

And negative integers 5, Its original code 、 Inverse code 、 The complement is exactly like this :

Original code :1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1

Inverse code :1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0

Complement code :1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1

Integer when stored , The highest bit is the sign bit ,0 It means a positive number ,1 A negative number . therefore 5 The highest bit of the original code of is 0,-5 The highest bit of the original code of is 1. and The inverse of a negative number It is based on the original code , The highest bit, that is, the sign bit remains unchanged , Other bits are reversed ; Complement is to add... To the inverse binary 1. Last but not least , Integers are stored in memory as complements !!!

原网站

版权声明
本文为[Fried tomatoes 110]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020519105928.html