当前位置:网站首页>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 |
边栏推荐
- Magics 23.0 how to activate and use the slice preview function of the view tool page
- Devaxpress Chinese description --tcxpropertiesstore (property store recovery control)
- Super complete regular expressions
- Compiling minicom-2.7.1 under msys2
- LabVIEW大型项目开发提高质量的工具
- [learn FPGA programming from scratch -22]: Advanced chapter - Architecture - Design and modeling of FPGA internal hardware circuit
- On February 26, 2022, the latest news of national oil price adjustment today
- How many times does the constructor execute?
- Service creation and operation example of ROS
- Record the VMware installation process of VMware Tools and some problems encountered
猜你喜欢

Network communication tcp/ip

leetcode743. Network latency (medium, Dijkstra)

Establishment of microservice development environment

Use koa to mock data and set cross domain issues

Alertwindowmanager pop up prompt window help (Part 1)

一种不带CPU的DPU架构:Hyperion

leetcode743. 网络延迟时间(中等, dijkstra)

Devaxpress Chinese description -- tdxgallerycontrol object (gallery component)
![[MathType] use MathType to output latex style formula](/img/46/ac2041fbc2eb90474e2e2d7d1b0a40.png)
[MathType] use MathType to output latex style formula

五、库存查询功能的完善
随机推荐
Detailed understanding of white noise
Detailed explanation of audience characteristics
Devaxpress Chinese description --tcximagelist (enhanced image list control)
三、上传织物图片至SQL Server并提供name进行展示织物照片
Magics 23.0如何激活和使用视图工具页的切片预览功能
About inquirerjs
Large end storage and small end storage
Unity jsonutility failed to serialize list
Temporary objects and compilation optimization
Service creation and operation example of ROS
Explanation and application of prefix sum (one-dimensional, two-dimensional)
Stone from another mountain: Web3 investment territory of a16z
Matplotlib drawing Chinese garbled code
Devaxpress Chinese description --tcxpropertiesstore (property store recovery control)
路径字段是什么? ——竞价广告
[andoid][step pit]cts 11_ Testbootclasspathandsystemserverclasspath at the beginning of R3_ Analysis of nonduplicateclasses fail
How do you use your own data to achieve your marketing goals?
Numpy multidimensional array transpose transpose
Calculation of accuracy, recall rate, F1 value and accuracy rate of pytorch prediction results (simple implementation)
V-inline-date, similar to Ctrip, flying pig, time selection with price