当前位置:网站首页>How to learn C language and share super detailed experience (learning note 1 -- basic data types of C language)
How to learn C language and share super detailed experience (learning note 1 -- basic data types of C language)
2022-06-13 01:47:00 【It's Beichen bupiacra】
Preface :
If you are learning C Language without knowing where to start , You can study with me C Language , During the winter vacation, I will post a blog every day , There are all kinds of C The knowledge of language , If you want to learn , Want to improve , Come and punch in with me every day , I hope we can make progress together .
C The basic data types of language
One 、 integer
According to the occupied memory size and the range of values that can be represented It can also be divided into short integers 、 Standard integer 、 Long integer 、 And long integer , Use keywords respectively short int、int、long int、long long int, Express .
1. Binary system 、 position 、 byte
The minimum storage unit of memory is bytes (Byte), One byte has 8 position (Bit)( That is, one byte can be stored 8 Binary “0” or “1”).
High on the left , On the right is the low position , The highest bit is the sign bit ,(“0” For a positive number ,“1” It's a negative number ) All that's left is the data bits .
A byte 8 The range of values that bits can represent ranges from -128(1000 0000)~127(0111 1111), common 256 individual .
Two bytes 16 The range of values that bits can represent ranges from -32768(1000 0000 0000 0000)~32767(0111 1111 1111 1111), common 65536 individual .
According to different values , Use memory space of different size bytes , No waste of memory space , And can put the corresponding value , Truly accomplish “ make ”.
| type | keyword | Take up memory | Value range |
|---|---|---|---|
| Short | short int | 2 byte | -32768~32767 |
| Standard integer | int | 4 byte | -2147483648~2147483647 |
| Long integer | long int | 4 byte | -2147483648~2147483647 |
| long long | long long int | 8 byte | -9223372036854775808~9223372036854775807 |
2. Unsigned integer
For this kind of unsigned bit , Integer types that are all data bits , We call it unsigned integer , Its keyword is unsigned. The four types of integers mentioned earlier are all signed integers , They also have a keyword signed, But usually you don't have to write , That is, the default integer is signed , If you want to use unsigned integers , prefix unsigned Key words can be used .
| type | keyword | Take up memory | Value range |
|---|---|---|---|
| Unsigned short | unsigned short int | 2 byte | 0~65535 |
| Unsigned standard integer | unsigned int | 4 byte | 0~4294967295 |
| Unsigned long | unsigned long int | 4 byte | 0~4294967295 |
| Unsigned long integer | unsigned long long int | 8 byte | 0~18446744073709551615 |
Two 、 Real type
C This kind of numeric type with decimal point is called real type or floating-point number type in . Although there is only one word difference between real type and integer type , But it does have a completely different way of storing memory than integer .
The real type is stored in three segments : Sign bit 、 Order code point 、 Data bits 
Memory size and value range of real type
| type | keyword | Take up memory | precision | Value range |
|---|---|---|---|---|
| Single precision floating point type | float | 4 byte | 6~7 Significant digits | -3.402823E+038~3.402823E+038 |
| Double precision floating point type | double | 8 byte | 15~16 Significant digits | -1.797693E+308~1.797693E+308 |
| Long double precision floating-point number type | long double |
3、 ... and 、 Character
The character keyword is char, A character type is an integer type of a byte .
first C The language specifies that a byte integer is used as a character , To be more exact , Yes, it will 0~127 this 128 Use a positive integer as a character , This is the famous ASCII code ( American standard code for information exchange ).
Character memory size and value range
| type | keyword | Take up memory | Value range |
|---|---|---|---|
| Character | char | 1 byte | -128~127 |
| No sign character type | unsigned char | 1 byte | 0~255 |
边栏推荐
- JSON and protobuf Any interchange
- 万字讲清 synchronized 和 ReentrantLock 实现并发中的锁
- A DPU architecture without CPU: Hyperion
- MySQL download and installation
- 6、 Implementation of warehouse out management function
- DFS and BFS to solve Treasure Island exploration
- 如何通过受众群体定位解决实际问题?
- What is the path field—— Competitive advertising
- [wsl2] restrict wsl2 accessible hardware resources (cpu/ memory)
- [MySQL password management] - [administrator password known, unknown (forgotten), cracked]
猜你喜欢

关于tkinter.Canvas 不显示图片的问题

Magics 23.0如何激活和使用视图工具页的切片预览功能

5、 Improvement of inventory query function

3、 Upload fabric photos to SQL server and provide name to display fabric photos

开发者来稿|AMD赛灵思中文论坛分享 - 提问的智慧

DFS and BFS to solve Treasure Island exploration

Implementation of pointer linked list

指针链表的实现

Devaxpress Chinese description --tdximageslider (picture rotation control)

General IP address, account and password of mobile IPv6 optical cat login, and mobile optical cat is in bridging mode
随机推荐
Devaxpress Chinese description --tdximageslider (picture rotation control)
Numpy multidimensional array transpose transpose
Matplotlib drawing Chinese garbled code
matplotlib画图中文乱码
Use mediapipe+opencv to make a simple virtual keyboard
[MathType] use MathType to output latex style formula
DFS and BFS to solve Treasure Island exploration
Vs how to enter chromium subprocess debugging
A DPU architecture without CPU: Hyperion
一种不带CPU的DPU架构:Hyperion
csdn涨薪技术之Jmeter接口测试数据库断言的实现与设计
【MathType】利用MathType输出LaTex样式的公式
Delphi7 compressed pictures (BMP, JPG, PNG)
How many times does the constructor execute?
How does Google's audience work?
Restful interface specification annotation of pringboot (2)
Introduction to common ROS commands
【软考】软件设计师知识点整理(待更新)
Read routing table
Magics 23.0如何激活和使用视图工具页的切片预览功能