当前位置:网站首页>Subtotal of C language -- basic data types and their representations
Subtotal of C language -- basic data types and their representations
2022-06-29 06:18:00 【Chlorella of bit】
c The basic data types of the language include integer data 、 Real data and character data .
【1】 Constants and variables
(1) Constant
A constant is an amount whose value cannot be changed while a program is running , It is c One of the basic data objects used in the . Constants are divided into numerical constants and character constants , Numerical constants are divided into integer constants and real constants , Character constants are divided into character constants and string constants .
These types determine the size of the space occupied by various constants and the representation range of numbers .
(2) Symbolic constant
stay c In language , Constants are expressed directly in the form of their own existence , It can also be represented by an identifier , Symbolic constants .
c Language uses macro definition commands to define symbolic constants , Its definition is as follows :
#define identifier Constant
among #define Is a special definer for macro definition commands , An identifier is the name of a constant , A constant can be any kind of constant .
The functions of macro definitions are : During compilation preprocessing , Replace all symbolic constants that appear after the macro definition command in the program with the corresponding constants in the macro definition command one by one . Therefore, symbolic constants are also called macro substitution names .
(3) Variable
A variable is an amount whose value can be changed during program operation . Variables here are two completely different concepts from variables in mathematics , stay c In language , Variable is the basic concept of data storage . We know , At the level of computer hardware , When the program is running, the data is stored by internal memory 、 Storage unit 、 Storage address and a series of related mechanisms , The reflection of these mechanisms in the programming language is the concept of variables .
A variable in a program can be regarded as a container for storing data . There are two basic operations on variables :{1} Put data values into variables , This operation is called : assignment ;{2} Get the current value of the variable to use , be called : Value . Variables have the property of holding values , After assignment , You will get this value every time you use this variable .
Programs use variables by their names . stay c In language , The variable name is the identifier of the variable , Its naming rules comply with all provisions of the identifier .
c The basic variable types provided by the language are : Numerical variable ( It is also divided into integer variables and real variables )、 Character variables 、 Pointer to the variable .
{ Definition of variables }
c Language program requirements , Each variable must first be defined , That is, to declare its existence first , To be able to use it . Defining variables requires two aspects of information : Variable name and its type , To determine its storage structure and make c Language compiler allocates storage space for defined variables .
【2】 Shaping data and its representation
(1) Integer types 、 Integer variables Be careful : Since the shaping data is represented by binary complement , So the range of negative numbers is larger
plastic 2 byte -32768~32767 (short\signed)int
Long integer 4 byte -2147483648~2147483647 long
Unsigned integer 2 byte 0~65535 unsigned
Unsigned long shaping 4 byte 0~4294967295
(2) integer constants
Decimal system
octal : In numbers 0 start Such as :056 It's equivalent to the decimal system 46 017 It's equivalent to the decimal system 15
Hexadecimal : With 0x perhaps 0X start hinder a,b,c,d,e,f It can also be capitalized . Such as :0x123 The decimal equivalent of 291
(3) Long integer constants
Add... After the constant l perhaps L that will do . for example :40000 Is an illegal decimal integer constant , but 40000L Is a legal decimal long constant .
【3】 Real data and its representation
边栏推荐
- VLAN experiment
- After “Go to Definition”, is there a command to return to where you came from?
- 2022.02.14
- Week 10 - task 3- from point to circle to cylinder
- Conditional test, if and case conditional test statements of shell script
- Leetcode simple question: judging the color of a grid on a chess board
- CodeIgniter active record not equal - CodeIgniter active record not equal
- Slot
- 64 commonly used terms for data analysis, really all!
- What is the "danksharding" of V God Kop on Valentine's day?
猜你喜欢

Jenkins operation Chapter 5 trigger, configuration webhook, Jenkins parameterized construction

Quickly write MVVM code using source generators

Why are keys unordered in golang map

Summary of redis basic knowledge points

The simple problem of leetcode is to divide an array into three parts equal to sum

Analysis report on the investment market of the development planning prospect of the recommended NFT industry research industry in 2022 (the attachment is a link to the online disk, and the report is

Are there too many programmers in China at present?

Ti Click: quickly set up tidb online laboratory through browser | ti- team interview can be conducted immediately

Longest substring between two identical characters of leetcode simple question

Installing modules in pycharm
随机推荐
Benign competition will promote each other
Research Report on the new energy industry of recommended power equipment in 2022 industry development prospect market investment analysis (the attachment is a link to the network disk, and the report
Ctrip launched the "3+2" office mode. Are you sour?
Honeypot based on MySQL load data local INFILE
Difference between URI and URL
Rich material libraries make modeling easy and efficient for developers
Is there any difference between a=a+b and a+=b?
Ghost in the Log4Shell
Problems with MySQL database query
51 single chip microcomputer learning notes 7 -- Ultrasonic Ranging
P5 DS - component and document Association
Can I cast int to a variable of type byte? What happens if the value is larger than the range of byte type?
2022-02 Microsoft vulnerability notification
Loosely matched jest A value in tohavebeencalledwith - loose match one value in jest toHaveBeenCalledWith
Fault: ntfrs warning log for id13562
Summary of redis basic knowledge points
Pytest (7) -yield and termination function
The most complete machine learning model training process
Can use the mouse, will reinstall the computer system tutorial sharing
Meso tetra (4-N, N, n-trimethylaminophenyl) porphyrin (ttmapp) /meso tetra - [4- (BOC threonine) aminophenyl] porphyrin (TAPP thr BOC) supplied by Qiyue