- 2020-02-25 21:16
*views 6*- 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

- Python126 blogs
- Java119 blogs
- Flow Chart79 blogs
- Vue73 blogs
- MySQL35 blogs
- programing language35 blogs
- C++34 blogs
- Linux34 blogs
- more...

Daily Recommendation

views 8

©2020 ioDraw All rights reserved

Java exercises 1： Simply define a car class New photo album app launched by Microsoft ： Using cross platform framework React Native to write Chapter two Fundamentals of programming Programming exercises pandas Time order of webpack Code segmentation import()Vue slot slot： Default slot , Named slot , Scope slot Fundamentals of data analysis ——R language （ Processing missing values ）C++ Implementation of matrix meteor shower effect PostMan Advanced Usage , Interface MD5+Secret autograph Sign The 12th Blue Bridge Cup B group C/C++ Provincial competition