- 2020-02-25 21:16
*views 7*- programing language
- Complement
- C++
- Unsigned
- ⭐C/C++ Programming Notes
- Signed

Unsigned And Signed keyword

Signed：

By default, integer variables declared are signed types （char It's a little special ）, If you want to declare an unsigned type, you need to add a unsigned .

The difference between an unsigned version and a signed version is that an unsigned type can be saved 2 Positive integer data multiple of signed type , as 16 One in bit system int The range of data that can be stored is 32768~32767

, and unsigned The range of data that can be stored is 0~65535. Because in the computer , It is a complement in the form of integers . According to the highest position , If it is 1,

A signed number is a negative number ; If it is an unsigned number All are interpreted as positive numbers .

Each type of integer has a sign or not （unsigned ） And signed signed ） Two types , By default, integer variables declared are signed types （ char

It's a little special ）, If you want to declare an unsigned type, you need to add a unsigned . The difference between the unsigned version and the signed version is that the signed type needs to use a bit

To represent the positive and negative of a number , such as 16 One in bit system int The range of data that can be stored is 32768 ~ 3276716 position 2 The highest bit of the base is used as the sign bit ‘ It's negative ‘

Be positive ）, and unsigned The range of data that can be stored is 0~65535 （ This highest bit does not need to be a sign bit , So it is 2 Of 16 Power , altogether 65536 ）. Because in the computer

An integer is a complement Stored in the form of . According to the highest position , If it is 1, A signed number is a negative number ; If it is an unsigned number All are interpreted as positive numbers . At the same time, in the case of the same number of digits

The range of integers that can be expressed becomes larger . in addition ,unsigned If the latter keyword is omitted ,== Most compilers think it is unsigned int ===.

Unsigned：

Each type of integer is divided into ： No sign （unsigned ） And signed signed ） Two types float and double It's always signed ）, In addition to char

Data types other than , By default, integer variables declared are signed types ; char Always unsigned by default . In addition to char Data types other than , If you need to declare an unsigned class

Type, you need to add before the type unsigned . The difference between an unsigned version and a signed version is that an unsigned type can be saved 2 Positive integer data multiple of signed type , such as 16 One in bit system

short The range of data that can be stored is 32768~32767 , and unsigned The range of data that can be stored is 0~65535

. Because in the computer, integers are stored in the form of complements . According to the highest position , If it is 1, A signed number is a negative number ; If it is an unsigned number All are interpreted as positive numbers . in addition , unsigned

If the latter keyword is omitted , majority compiler Would think it was unsigned int .

Each type of integer has a sign or not （ unsigned ） And signed signed ） Two types , Declared by default Integer variable They're all signed types （ char It's a little special ）

=, If you want to declare an unsigned type, you need to add a unsigned . The difference between the unsigned version and the signed version is that the signed type needs to use a bit To represent the positive and negative of a number , such as 16

One in bit system int The range of data that can be stored is 32768 ~ 32767（16 position 2 The highest bit of the base is used as the sign bit ‘ It's negative ‘ Be positive ）, and unsigned

The range of data that can be stored is 0~65535 （ This highest bit does not need to be a sign bit , So it is 2 Of 16 Power , altogether 65536 ）. Because in the computer whole The number is based on Complement

Stored in the form of . According to the highest position , If it is 1, A signed number is a negative number ; If it is an unsigned number All positive numbers are explained . At the same time, in the case of the same number of digits

The range of integers that can be expressed becomes larger . in addition ,unsigned If the latter keyword is omitted , Most compilers think it is unsigned int .

Technology

- Python156 blogs
- Java139 blogs
- Vue91 blogs
- Flow Chart80 blogs
- javascript44 blogs
- C++43 blogs
- algorithm41 blogs
- programing language40 blogs
- more...

Daily Recommendation

views 5

views 3

views 2

views 2

©2020-2021 ioDraw All rights reserved

orm What are the frameworks _java Which technologies are necessary ?Circular radar chartSQL Different values for the same field in , Conduct data statistics Summary of physical knowledge points For beginners Python Is development difficult to learn ? Is it suitable for beginners ? How ABC The three threads execute ten times in sequence “Python Is the best language in the world ”Vue cache algorithm, LRU policy algorithmVue component communication modeStruts2 Deserialization vulnerability recurrence