当前位置:网站首页>[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 .
边栏推荐
- Deep exploration of functions with indefinite parameters in C language
- Is it appropriate for a 27 - year-old girl to change her career from zero to software testing?
- 安全生产月知识竞赛——新安法知多少
- Coordinates of the capital of each province in China
- Today's sleep quality record 80 points
- 浅析直播间海量聊天消息的架构设计难点
- 爱思唯尔---Elseviewer---预印本在线发表通知
- 【Qt】error: QApplication: No such file or directory 解决方案
- ASEMI场效应管12N65参数,12N65规格书,12N65特征
- [music] playing blue and white porcelain based on MATLAB [including Matlab source code 1873]
猜你喜欢

ME11/ME12采购信息记录及条件记录创建及更新BAPI:ME_INFORECORD_MAINTAIN_MULTI

SAP SMARTFORMS文本内容手动换行输出

The annual salary of testers in large factories ranges from 300000 to 8K a month. Roast complained that the salary was too low, but he was ridiculed by netizens?

Asemi FET 12n65 parameters, 12n65 specifications, 12n65 features

Dinner a bang's Craft

腾讯测试开发岗面试上机编程题
![[BSP video tutorial] BSP video tutorial issue 17: single chip microcomputer bootloader topic, startup, jump configuration and various usage of debugging and downloading (2022-06-10)](/img/69/1e2a71f123527b9aa8381cb9b86f7f.png)
[BSP video tutorial] BSP video tutorial issue 17: single chip microcomputer bootloader topic, startup, jump configuration and various usage of debugging and downloading (2022-06-10)

Internet of things final assignment - sleep quality detection system (refined version)

Video compression data set TVD

Task02: linked list
随机推荐
[matlab] basic image operation (point operation, arithmetic operation, scaling and rotation)
【MATLAB】图像基本运算(点运算、算术运算、缩放、旋转)
Learning C language from scratch day 040
[leetcode] notes on recursive time value transfer and reference transfer
[penetration test tool bee] how to install and use the XSS penetration test tool bee?
Task01: be familiar with the basic process of news recommendation system
Can the soft exam certificate be settled in Shanghai? Many people don't know
SAP smartforms page feed printing automatic judgment
[traffic sign recognition] Based on Matlab GUI YCbCr feature extraction +bp neural network traffic sign recognition [including Matlab source code 1869]
[matlab] image transform (Fourier transform, discrete cosine transform)
[winning] Title A of the 9th Teddy Cup Challenge
[matlab] image restoration
ABAP CDS实现多行字段内容拼接
双面材质【double sided】的Shader
JS Part 5
软件测试面试复盘:技术面没有难倒我,hr面却是一把挂
5月B站榜单丨飞瓜数据UP主成长排行榜(B站平台)发布
The interviewer of Tencent said that who knows the internal module index principle and performance optimization idea of MySQL architecture?
switch case使用枚举类来比较
Asemi FET 12n65 parameters, 12n65 specifications, 12n65 features