Home > Operation and Maintenance > Windows Operation and Maintenance > What is unsigned in computer programming

What is unsigned in computer programming

藏色散人
Release: 2019-01-19 09:42:58
Original
6880 people have browsed it

In computer programming, the term "unsigned" refers to a variable that can only hold positive numbers. "Signed" in computer code means that a variable can contain negative and positive values. This property applies to most numeric data types, including int, char, short, and long.

What is unsigned in computer programming

Unsigned variable integer type

The int of the unsigned variable type can contain zero and positive numbers, while the signed int can contain Negative numbers, zero and positive numbers.

In 32-bit integers, the range of unsigned integers is 0 to 232-1 = 0 to 4,294,967,295, which is approximately 4 billion. The signed version goes from -231-1 to 231, which is -2,147,483,648 to 2,147,483,647, or - 2 billion to 2 billion. The range is the same, but moved on the number line.

By default, the int type in C, c and c# is signed. If negative numbers are involved, the programmer must change to unsigned.

Unsigned characters

For characters with only 1 byte, the range of unsigned characters is 0 to 256, while the range of signed characters is -127 to 127 .

Independent type specifiers and other uses

Unsigned (and signed) can also be used as independent type specifiers, but if used individually, they default to int .

Objects of type long can be declared as signed long or unsigned long. Signed long is the same as long because signed is the default.

The above is the detailed content of What is unsigned in computer programming. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template