当前位置:网站首页>Things about data storage 2
Things about data storage 2
2022-07-07 05:47:00 【It's Yi'an】
Part1: Original code , Inverse code , Complement code Signed number ? Sign bit Value bits integer
According to what rules is the data stored in the computer ? So let's see , Original code , Inverse code , Complement code .
According to the definition, the negative integer original code with sign, the inverse code and complement are different , Unsigned and positive numbers are the same .
The first bit is the sign bit , It's all used 0 Express positive ,1 Negative . The numerical digits are all different
Part2:-10 Integers Complement code Why? adder Unification of addition and subtraction
Let's give you an example int:-10, We know that an integer occupies 4 Bytes
00000000 00000000 00000000 00000000; empty : The general situation is not 0
10000000 00000000 00000000 00001010; Original code
11111111 11111111 11111111 11110101; Inverse code
11111111 11111111 11111111 11110110; Complement code
ff ff ff f6; Hexadecimal representation
In the computer , Integer data is represented by hexadecimal complement
Why do this ?
This is related to the structure of the computer , As I thought before , Use signals to represent the form of numbers , These figures will be used after all , The basic algorithm between numbers , How to realize addition and subtraction , It's easy to think about it with us 1+1, be equal to 2, How to add and subtract in the computer ?
Add , Before learning the principles of computer composition , First we know that addition is the addition of signals at two positions , Use a component , When both are 1 If yes, it becomes 0, At the same time, the latter one becomes 1(0) Or 0(1). What about subtraction 1 become 0,0 become 1 Do you ? This is the same as addition ? How to distinguish ? In those days , When the complement of the original code has not appeared , To solve this problem , Someone put forward the concept of original code, inverse code and complement , a pile 101010 Explore , Now it seems very reasonable , Know this rule , It's a bit like the Berlin Wall . The existence of complement allows subtraction to do addition .
Part3:
Large and small end Memory block Low address Pattern The way Byte order
When we are opening up space , The opened space is called memory block , By number , It has high address side and low address side , The same data 0x11223344,0x High position … status .
We put it in memory block in bytes , Obviously, there are many sorting methods , The two most used methods are to put the high address in the low place , Low address to high and high address to high , Put the low address low , Two ways , The former is called big end mode , The latter is called small end mode . Because it is put in bytes , There is the word byte order .
Part4:
char %d Improve the overall shape %u
It was said before char Type can be put into integer , but char It takes only one byte , When an integer data is put into char In the middle of the day , Press 32 Bits are first converted to complements , Only the last byte put in is the low byte . When char To use %d When the output , We need to improve the integer first , If the first one is 1, Make up 1 To 32 position , if 0 Then fill 0( Only negative integers complement 1, Because its original code, inverse code and complement are different )
%u It's an unsigned integer , Judge before complement conversion ( After integer lifting )
Part5:
char Range Complement code With or without symbols repair 1000 0000 circle +1 Change sign 128
char Types are divided into signed and unsigned , It is also stored in memory in the form of complement 、
The signed range is ·-128—>127:01111111(127)+1=10000000(-128)
The unsigned range is 0à255:00000000(0)à11111111(255)
We know that the complement in memory needs to be reduced by one , But symbolic ·10000000 It will automatically convert here -128. And because of the complement , ad locum 127+1=-128.
边栏推荐
- 原生小程序 之 input切换 text与password类型
- 往图片添加椒盐噪声或高斯噪声
- Pinduoduo product details interface, pinduoduo product basic information, pinduoduo product attribute interface
- Explication contextuelle du langage Go
- Cve-2021-3156 vulnerability recurrence notes
- Unity让摄像机一直跟随在玩家后上方
- 上海字节面试问题及薪资福利
- 【已解决】记一次EasyExcel的报错【读取xls文件时全表读不报错,指定sheet名读取报错】
- Hcip eighth operation
- C nullable type
猜你喜欢
Leetcode 1189 maximum number of "balloons" [map] the leetcode road of heroding
Distributed global ID generation scheme
What is dependency injection (DI)
Paper reading [semantic tag enlarged xlnv model for video captioning]
Differences and introduction of cluster, distributed and microservice
Leakage relay jelr-250fg
基于NCF的多模块协同实例
WEB架构设计过程
JSP setting header information export to excel
[论文阅读] Semi-supervised Left Atrium Segmentation with Mutual Consistency Training
随机推荐
sql查询:将下一行减去上一行,并做相应的计算
How does mapbox switch markup languages?
Nodejs get client IP
[论文阅读] Semi-supervised Left Atrium Segmentation with Mutual Consistency Training
Hcip eighth operation
消息队列:如何确保消息不会丢失
EMMC打印cqhci: timeout for tag 10提示分析与解决
4. 对象映射 - Mapping.Mapster
论文阅读【Semantic Tag Augmented XlanV Model for Video Captioning】
Pinduoduo product details interface, pinduoduo product basic information, pinduoduo product attribute interface
Leetcode 1189 maximum number of "balloons" [map] the leetcode road of heroding
消息队列:消息积压如何处理?
JVM the truth you need to know
Jhok-zbg2 leakage relay
ssm框架的简单案例
Hcip seventh operation
High voltage leakage relay bld-20
【已解决】记一次EasyExcel的报错【读取xls文件时全表读不报错,指定sheet名读取报错】
【Shell】清理nohup.out文件
C#可空类型