当前位置:网站首页>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;
}
边栏推荐
- Low success rate of unit test report
- Tuowei information uses the cloud native landing practice of rainbow
- GFS distributed file system
- Kotlin combines flatmap for filtering and zip merge operators
- Easy to understand SSO
- 数据中台落地实施之法
- Grpc, oauth2, OpenSSL, two-way authentication, one-way authentication and other column directories
- IELTS review progress and method use [daily revision]
- AVL平衡二叉搜索树
- [paper reading] icml2020: can autonomous vehicles identify, recover from, and adapt to distribution shifts?
猜你喜欢
【无标题】
[quick start of Digital IC Verification] 12. Introduction to SystemVerilog testbench (svtb)
[quick start of Digital IC Verification] 10. Verilog RTL design must know FIFO
Don't stop chasing the wind and the moon. Spring mountain is at the end of Pingwu
One click deployment of highly available emqx clusters in rainbow
Tuowei information uses the cloud native landing practice of rainbow
饥荒云服管理脚本
Exercise arrangement 2.10, 11
Coquette data completes the cloud native transformation through rainbow to realize offline continuous delivery to customers
Iptables' state module (FTP service exercise)
随机推荐
Train your dataset with swinunet
Tuowei information uses the cloud native landing practice of rainbow
CCTV is so warm-hearted that it teaches you to write HR's favorite resume hand in hand
BiSeNet的特点
Analysis of maker education in innovative education system
Openjudge noi 2.1 1752: chicken and rabbit in the same cage
MES系统,是企业生产的必要选择
解读创客思维与数学课程的实际运用
Using helm to install rainbow in various kubernetes
Offer harvester: add and sum two long string numbers (classic interview algorithm question)
A method for quickly viewing pod logs under frequent tests (grep awk xargs kuberctl)
【雅思口语】安娜口语学习记录 Part2
Basic use of CTF web shrink template injection nmap
Four items that should be included in the management system of integral mall
POJ - 3616 Milking Time(DP+LIS)
Rainbond结合NeuVector实践容器安全管理
Rsync remote synchronization
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
DeiT学习笔记
Lua programming learning notes