当前位置:网站首页>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 |
边栏推荐
- Pyflink implements custom sourcefunction
- Add default right-click menu
- [andoid][step pit]cts 11_ Testbootclasspathandsystemserverclasspath at the beginning of R3_ Analysis of nonduplicateclasses fail
- Numpy multidimensional array transpose transpose
- TensorFlow 2.x 多显卡分布式训练
- Getting started with phaser 3
- 深度学习调参技巧详解
- Padavan mounts SMB sharing and compiles ffmpeg
- Reinstall opencv and step on the pit.
- Devexpress implementation flow chart
猜你喜欢

五、库存查询功能的完善

Startup, connection and stop of MySQL service

Use mediapipe+opencv to make a simple virtual keyboard

LabVIEW大型项目开发提高质量的工具

DFS and BFS to solve Treasure Island exploration

服务器安装jupyterlab以及远程登录配置

Alertwindowmanager pop up prompt window help (Part 1)

谷歌的受众群体是如何发挥作用的?

路径字段是什么? ——竞价广告

开发者来稿|AMD赛灵思中文论坛分享 - 提问的智慧
随机推荐
5、 Improvement of inventory query function
Using OpenCV in go
Padavan mounts SMB sharing and compiles ffmpeg
Use koa to mock data and set cross domain issues
Magics 23.0 how to activate and use the slice preview function of the view tool page
Explanation and application of prefix sum (one-dimensional, two-dimensional)
[learn FPGA programming from scratch -21]: Advanced - Architecture - VerilogHDL coding specification
Network communication tcp/ip
Magics 23.0如何激活和使用视图工具页的切片预览功能
URI, URL and urn difference, relation and syntax diagram
四、入库管理功能的完善
Anims of phaser3
How to solve practical problems through audience positioning?
Numpy multidimensional array transpose transpose
PyFlink实现自定义SourceFunction
This of phaser3 add. sprite
Torch. Distributions. Normal
Service creation and operation example of ROS
Introduction to Google unit testing tools GTEST and gmoke
Stone from another mountain: Web3 investment territory of a16z