当前位置:网站首页>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.
边栏推荐
- The year of the tiger is coming. Come and make a wish. I heard that the wish will come true
- 【日常训练--腾讯精选50】292. Nim 游戏
- What is dependency injection (DI)
- 力扣102题:二叉树的层序遍历
- Flink SQL realizes reading and writing redis and dynamically generates hset key
- AI人脸编辑让Lena微笑
- zabbix_get测试数据库失败
- SQLSTATE[HY000][1130] Host ‘host. docker. internal‘ is not allowed to connect to this MySQL server
- Pinduoduo product details interface, pinduoduo product basic information, pinduoduo product attribute interface
- English语法_名词 - 所有格
猜你喜欢

产业金融3.0:“疏通血管”的金融科技

Hcip seventh operation

Web architecture design process

Message queue: how to deal with message backlog?

SQL query: subtract the previous row from the next row and make corresponding calculations

5. 数据访问 - EntityFramework集成

4. 对象映射 - Mapping.Mapster

How does mapbox switch markup languages?

Leakage relay jd1-100

集群、分布式、微服務的區別和介紹
随机推荐
论文阅读【Semantic Tag Augmented XlanV Model for Video Captioning】
纪念下,我从CSDN搬家到博客园啦!
SAP webservice 测试出现404 Not found Service cannot be reached
Dynamic memory management
Wechat applet Bluetooth connects hardware devices and communicates. Applet Bluetooth automatically reconnects due to abnormal distance. JS realizes CRC check bit
Lombok plug-in
In memory, I moved from CSDN to blog park!
English语法_名词 - 所有格
C#可空类型
Leetcode: maximum number of "balloons"
集群、分布式、微服务的区别和介绍
4. Object mapping Mapster
AI人脸编辑让Lena微笑
毕业之后才知道的——知网查重原理以及降重举例
软件测试面试技巧
sql查询:将下一行减去上一行,并做相应的计算
5. 数据访问 - EntityFramework集成
CVE-2021-3156 漏洞复现笔记
Win configuration PM2 boot auto start node project
ForkJoin最全详解(从原理设计到使用图解)