当前位置:网站首页>[C language] storage of data in memory -1 plastic
[C language] storage of data in memory -1 plastic
2022-06-11 02:12:00 【Green abundance is not green】
primary coverage :
- C The data type of the language
- Original code 、 Inverse code 、 Complement code
- Plastic surgery Family
- Storage of shaping data in memory
C The data type of the language
| char | Character data type |
| short | Short plastic surgery |
| int | plastic |
| long | Long integer |
| long long | Longer plastic surgery |
| float | Single precision floating point |
| double | Double precision floating point |
The meaning of type
- Size determines the range of use , Determines the size of the memory space to be opened with this type
- Determines how memory space is viewed
Original code 、 Inverse code 、 Complement code
The original and inverse complements of positive integers are the same , The rules for the inverse and complement of negative integers are as follows
Original code : Directly translate binary into binary in the form of positive and negative numbers .
Inverse code : Put the original code of The sign bits remain the same , The other bits are in order According to the not You can get it .
Complement code : Inverse code +1 You get the complement .( All the shaping data stored in memory are complements )
Such as four byte integer -1:
| Original code | 10000000 00000000 00000000 00000001 |
| Inverse code | 11111111 11111111 11111111 11111110 |
| Complement code | 11111111 11111111 11111111 11111111 |
Plastic surgery Family
char { unsigned char , signed char }
short { unsigned short , signed short }
int { unsiged int , signed int }
long { unsigned long , signed long}
char Type is also a type of shaping , because char The characters in will be converted to ASCII The code is stored in memory , and ASCII All codes are integers
Each type of shaping will contain A signed signed and Unsigned unsigned Two types of , The difference between these two types is the sign bit difference in binary , If not add signed, The default shape is signed type
Signed integers are signed Decorated integer , The highest bit in binary is the sign bit ,1 A minus sign ,0 A positive sign
Unsigned integers are unsigned Decorated integer , The highest bit in binary represents a number
Like binary 11111111, if char, said -177, if unsigned char, said 255;
Storage of shaping data in memory

Four byte integer a=20, The complement is expressed in binary as 00000000 00000000 00000000 00010100, Expressed in hexadecimal as 0x00 00 00 14,
b=-10 The complement is expressed in binary as 11111111 1111111 1111111 11110110, Expressed in hexadecimal as 0xff ff ff f6,
And we found that they are stored in memory in reverse , This is related to the storage mode of the compilation environment
- Big end ( Storage ) Pattern , The low bit of data is stored in the high address of memory , And the high end of the data , Stored in a low address in memory ;
- The small end ( Storage ) Pattern , The low bit of data is stored in the low address of memory , And the high end of the data ,, Stored in a high address in memory
So the storage mode in the above figure is the small end storage mode .
for example : One 16bit Of short type x , The address in memory is 0x0010 , x The value of is 0x1122 , that 0x11 by
High byte , 0x22 Is low byte .
For big end mode , will 0x11 Put it in the low address , namely 0x0010 in , 0x22 Put it in a high address , namely 0x0011 in . The small end model , Just the opposite .
边栏推荐
- Learning C language from scratch day 040
- The interviewer of Tencent said that who knows the internal module index principle and performance optimization idea of MySQL architecture?
- InfoQ 极客传媒 15 周年庆征文|容器运行时技术深度剖析
- [matlab] basic image operation (point operation, arithmetic operation, scaling and rotation)
- Complete tutorial on obtaining voltage from QGC ground station (APM voltage cannot be obtained from QGC)
- [penetration test tool bee] how to install and use the XSS penetration test tool bee?
- 【MATLAB】图像分割
- ---排列数字---
- [matlab] image enhancement (power transformation, histogram specification processing method, smoothing and sharpening filtering)
- How to change the administrator's Avatar in win11? Win11 method of changing administrator image
猜你喜欢

How to change the theme of win11 touch keyboard? Win11 method of changing touch keyboard theme

adb 常用命令解析

Union find

Complete tutorial on obtaining voltage from QGC ground station (APM voltage cannot be obtained from QGC)

5月B站榜单丨飞瓜数据UP主成长排行榜(B站平台)发布

爱思唯尔---Elseviewer---预印本在线发表通知
![[music] playing](/img/cf/63b04080867e93ab2e00e2e21b37df.jpg)
[music] playing "over fire" based on MATLAB [including Matlab source code 1875]

How to change the administrator's Avatar in win11? Win11 method of changing administrator image

Analysis of common ADB commands

Dinner a bang's Craft
随机推荐
[leetcode] breadth first search level traversal general disassembly template
Understand the role of before and after Clearfixafter clear floating
Orcale driver
腾讯测试开发岗面试上机编程题
Me11/me12 purchase information record and condition record creation and update bapi:me_ INFORECORD_ MAINTAIN_ MULTI
Learning C language from scratch day 040
QT widget's simple serial port assistant (qserialport)
从测试零基础到测试架构师,这10年,他是这样让自己成才的
[matlab] image segmentation
During SSH configuration key login, you need to pay attention to whether the private key is set with a password
Oracle tablespaces, users, and authorization to users
FB02编辑Coding Block字段
Task01: be familiar with the basic process of news recommendation system
Understanding of pointers
Task07: double pointer
Is it correct to declare an array in this way? int n=10,a[n]; What if so? const int n =10; int a[n];
Treatment of small fish
Talk about an annotation implementation interface retry
adb 常用命令解析
switch case使用枚举类来比较