当前位置:网站首页>Data type - integer (C language)
Data type - integer (C language)
2022-07-07 08:30:00 【It's a dream, it's you!】
Catalog
1 The expression and storage form of integer
1.3 The representation of integers
1.4 The storage form of integers
2 Various base numbers and their conversion
2.2 Decimal system - - > Binary system
3 Each integer type and the number of bytes it occupies
3.2 Factors affecting the number of bytes
3.3 Number of bytes occupied by each type
3.4 Number of bytes occupied by each type
4.1 All integer output controllers
1 The expression and storage form of integer
1.1 Integer classification
Include : Basic integers intShort short intLong integer long intDouble long integers long long int C991.1 Extension type
[signed] short [int] Signed short integersunsigned short [int] Unsigned Short[signed] int Signed basic integerunsigned [int] Unsigned Basic integers[signed] long [int] Signed long integerunsigned long [int] Unsigned Long integer[signed] long long [int] Signed double long integer (C99 newly added )unsigned long long [int] Unsigned Double long integers (C99 newly added )1.3 The representation of integers
By polarity : Positive numbers 、 Negative and zero .In hexadecimal : Binary system 、 octal 、 Decimal system 、 Hexadecimal etc .1.4 The storage form of integers
In the computer memory, it is in accordance with Binary system Complement code form Storage Of .(1) Original codeBinary source code : Sign bit + Value bitshighest Symbol bitPositive numbers :0negative :1(2) Example of original code
just Count Original code 、 Inverse code 、 Complement code all identical(3) The inverse of a negative number 、 Complement code
Inverse code : Keep the sign bit of the negative original code unchanged , The value is inversed bit by bit .Complement code : Add the negative number to the inverse code 1 That is, its complement .
2 Various base numbers and their conversion
2.1 Base judgment basis
Prefix method : stay C in , Generally, the base is determined according to the prefix .Prefix 0( zero ) octal , Be careful : Numbers 0, Non alphabetic oPrefix 0x or 0X HexadecimalDefault Decimal system2.2 Decimal system - - > Binary system
2.3 octal
Numbers and rules :0~7 must With Numbers 0 start , Every eight enters one.give an example 1: Octal number 037 Represents the decimal number :
give an example 2: Decimal number 22 It can be expressed as :026,verification :2.4 Hexadecimal
Numbers and rules : from 0~9、A~F(a~f)16 Number , Every 16 to one .give an example 1:0x1f、0x1F、0X1f or 0X1F, The corresponding decimal numbers aregive an example 2: Decimal number 22 Can be expressed as :0x16 or 0X16 :
3 Each integer type and the number of bytes it occupies
3.1 Bits and bytes
position (bit): Processing data Smallest unit , Can only 0 or 1.byte (Byte): Processing data Basic unit , Usually a byte in the system is 8 position . namely 1 Byte=8 bit3.2 Factors affecting the number of bytes
Influencing factors : Machine number 、C Compiler, etc. .give an example :32 Bit system ,Turbo C Environment int 2 byte .32 Bit system ,VC++6.0 Environment int 4 byte .3.3 Number of bytes occupied by each type
short 2 byteint 2 or 4 bytelong 4 bytelong long 8 byteTools :sizeof The operator calculates the number of bytes occupied by each type in the environmentsizeof(int) sizeof(long)3.4 Number of bytes occupied by each type
C The standard does not specify the specific number of bytes occupied by each type , It is only specified that the number of bytes occupied by each integer type meets the following relationship :sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long)
4 Comprehensive case
4.1 All integer output controllers
%hd In decimal Short%d In decimal Basic integers%u In decimal Unsigned integer%ld In decimal Long integer%lo In octal Long integer%lh In hex Long integer4.2 Case study
#include<stdio.h>
int main(void)
{
unsigned int un_a=2500000000;
long l_b=65539;
printf("In this system:\n");
printf("short has %d bytes.\n",sizeof(short));
printf("int has %d bytes.\n",sizeof(int));
printf("long has %d bytes.\n",sizeof(long));
printf("un_a = %u not %d\n",un_a,un_a);
printf("l_b = %ld not %hd\n",l_b,l_b);
return 0;
}
边栏推荐
- Obsidan之数学公式的输入
- Bisenet features
- Rainbow combines neuvector to practice container safety management
- Zcmu--1396: queue problem (2)
- 在 Rainbond 中一键安装高可用 Nacos 集群
- Use of any superclass and generic extension function in kotlin
- Practice of combining rook CEPH and rainbow, a cloud native storage solution
- JS copy picture to clipboard read clipboard
- 2-3查找樹
- iptables 之 state模块(ftp服务练习)
猜你喜欢
Splunk子查询模糊匹配csv中字段值为*
Famine cloud service management script
Coquette data completes the cloud native transformation through rainbow to realize offline continuous delivery to customers
单场带货涨粉10万,农村主播竟将男装卖爆单?
PVTV2--Pyramid Vision TransformerV2学习笔记
BiSeNet的特点
2-3 lookup tree
Train your dataset with swinunet
解读创客思维与数学课程的实际运用
Open3D ISS关键点
随机推荐
[IELTS speaking] Anna's oral learning records Part3
XCiT学习笔记
Openvscode cloud ide joins rainbow integrated development system
National standard gb28181 protocol video platform easygbs adds streaming timeout configuration
[untitled]
Deit learning notes
Low success rate of unit test report
Rsync remote synchronization
Easy to understand SSO
在Rainbond中一键部署高可用 EMQX 集群
MES系統,是企業生產的必要選擇
Réplication de vulnérabilité - désrialisation fastjson
2-3 lookup tree
[hard core science popularization] working principle of dynamic loop monitoring system
Interpreting the practical application of maker thinking and mathematics curriculum
Opencv learning note 4 - expansion / corrosion / open operation / close operation
Four items that should be included in the management system of integral mall
Caractéristiques de bisenet
Use of out covariance and in inversion in kotlin
Transformation function map and flatmap in kotlin