当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
Give full play to the wide practicality of maker education space
探索STEAM艺术设计中的创造力
Golang compilation constraint / conditional compilation (/ / +build < tags>)
Rainbond 5.6 版本发布,增加多种安装方式,优化拓扑图操作体验
归并排序和非比较排序
一种适用于应用频繁测试下快速查看Pod的日志的方法(grep awk xargs kuberctl)
解析创新教育体系中的创客教育
Opencv learning note 5 - gradient calculation / edge detection
【无标题】
A method for quickly viewing pod logs under frequent tests (grep awk xargs kuberctl)
随机推荐
饥荒云服管理脚本
The reified keyword in kotlin is used for generics
JS copy picture to clipboard read clipboard
Bisenet features
Function extension, attribute extension and non empty type extension in kotlin
Installation and configuration of PLSQL
Opencv learning note 3 - image smoothing / denoising
The field value in Splunk subquery fuzzy matching CSV is*
PVTV2--Pyramid Vision TransformerV2学习笔记
Obsidan之数学公式的输入
2-3查找树
POJ - 3784 Running Median(对顶堆)
Kotlin combines flatmap for filtering and zip merge operators
Input of mathematical formula of obsidan
解读创客思维与数学课程的实际运用
在Rainbond中实现数据库结构自动化升级
The single value view in Splunk uses to replace numeric values with text
Transformation function map and flatmap in kotlin
Train your dataset with swinunet
Golang 编译约束/条件编译 ( // +build <tags> )