当前位置:网站首页>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
边栏推荐
- Rich material libraries make modeling easy and efficient for developers
- 51 lines of code, self-made TX to MySQL software!
- Overlay histogram with density curve
- P5 DS - component and document Association
- [C language series] - branch and loop statements
- Sum of digits under k-ary representation of leetcode simple problem
- 64 commonly used terms for data analysis, really all!
- Hyperledger Fabric 2. X custom smart contract
- Pytest (7) -yield and termination function
- Hyperledger Fabric 2. X custom smart contract
猜你喜欢

Hustoj SPJ example

Pytest (7) -yield and termination function

Internet enterprises need CRM software to help

Principle of screen printing adjustment of EDA (cadence and AD) software

Servlet version conflict causes page 404

Why can't the article be posted?

Pytest (7) -yield and termination function

Design risc-v processor from scratch -- data adventure of five stage pipeline

Fault: NetBt log for id4321

CCTV revealed that xumengtao won the black Technology: there was a virtual coach???
随机推荐
Boost the digital economy and face the future office | the launch of the new version of spreadjsv15.0 is about to begin
Review of MySQL knowledge points
Why is there a packaging type?
MySQL add / delete / modify query SQL statement exercise yyds dry goods inventory
Hustoj SPJ example
Hyperledger Fabric 2. X custom smart contract
The simple problem of leetcode is to divide an array into three parts equal to sum
Clickhouse data type
Openfpga wishes you a happy Lantern Festival!
QT (x): control operation
Servlet version conflict causes page 404
Fault: display Storport driver out of date in component health
Mongodb basic knowledge summary
Fault: ntfrs warning log for id13562
Failure: unable to log in to "taxpayer equity platform"
Are there too many programmers in China at present?
Games101 Lecture 10 geometry 1 Notes
Case of single file component files
2022.02.15
[chromium] win10 vs2019 environment chromium configuration and compilation.