当前位置:网站首页>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.
边栏推荐
- Web architecture design process
- 成为资深IC设计工程师的十个阶段,现在的你在哪个阶段 ?
- 【已解决】记一次EasyExcel的报错【读取xls文件时全表读不报错,指定sheet名读取报错】
- AI人脸编辑让Lena微笑
- Get the way to optimize the one-stop worktable of customer service
- Lombok plug-in
- 基于NCF的多模块协同实例
- 淘宝店铺发布API接口(新),淘宝oAuth2.0店铺商品API接口,淘宝商品发布API接口,淘宝商品上架API接口,一整套发布上架店铺接口对接分享
- 微信小程序蓝牙连接硬件设备并进行通讯,小程序蓝牙因距离异常断开自动重连,js实现crc校验位
- Egr-20uscm ground fault relay
猜你喜欢
Three level menu data implementation, nested three-level menu data
Web architecture design process
Lombok插件
C#可空类型
数据中心为什么需要一套基础设施可视化管理系统
Flink SQL 实现读写redis,并动态生成Hset key
三级菜单数据实现,实现嵌套三级菜单数据
Preliminary practice of niuke.com (9)
[reading of the paper] a multi branch hybrid transformer network for channel terminal cell segmentation
Dj-zbs2 leakage relay
随机推荐
Leetcode: maximum number of "balloons"
Reptile exercises (III)
What is message queuing?
爬虫练习题(三)
Digital innovation driven guide
Message queue: how to deal with message backlog?
Paper reading [MM21 pre training for video understanding challenge:video captioning with pre training techniqu]
AI face editor makes Lena smile
Go 语言的 Context 详解
消息队列:如何确保消息不会丢失
[paper reading] semi supervised left atrium segmentation with mutual consistency training
Jhok-zbg2 leakage relay
4. Object mapping Mapster
Educational Codeforces Round 22 B. The Golden Age
Mapbox Chinese map address
常用消息队列有哪些?
Leakage relay llj-100fs
Différenciation et introduction des services groupés, distribués et microservices
SAP ABAP BDC(批量数据通信)-018
《2022中国低/无代码市场研究及选型评估报告》发布