Home >Common Problem >What data type is uint16?

What data type is uint16?

藏色散人
藏色散人Original
2021-07-23 11:31:3426481browse

uint16 is a 16-bit unsigned integer type; integers have two types: unsigned and signed. By default, the integer variables declared are signed types. If you need to declare an unsigned type, You need to add unsigned before the type.

What data type is uint16?

The operating environment of this article: Windows7 system, DELL G3 computer

What is the data type of uint16?

uint16 is a 16-bit unsigned integer type, uint8 is an 8-bit unsigned integer type

There are two types of integer types: unsigned (unsigned) and signed (signed). By default, the integer variables declared are signed types (char is a bit special). If you need to declare an unsigned type, you need to add unsigned before the type. When it is impossible to take a negative value, it can be defined as unsigned. In some underlying embedded programming data, it is generally unsigned.

What data type is uint16?

Related introduction:

Conversion of signed integer type and unsigned integer type when negative number

When performing an operation ( As here a>b), if one of its operands is signed and the other is unsigned, then the C language will implicitly coerce the signed parameter to an unsigned number and assume that the two The numbers are all non-negative to perform this operation.

Integers usually exist in the form of complement in computers, and the complement of -1 (stored in 4 bytes) is 1111,1111,1111,1111. For most C language implementations, the general rule for converting between signed and unsigned numbers of the same word size is: the value may change, but the bit pattern does not.

That is to say, the underlying bit representation remains unchanged when unsigned int is cast to int, or int is converted to unsigned int. In other words, even after -1 is converted to unsigned int, its representation in memory has not changed, that is, 1111,1111,1111,1111.

The same storage representation may correspond to different data for the application. For example, 1111, 1111, 1111, 1111 represents -1 for signed numbers, but for unsigned numbers, it represents Represents UMax (because there is no sign bit, just like the complement of a positive number is itself, and the highest bit does not represent the sign bit), but their underlying storage is the same.

For more related knowledge, please visit the FAQ column!

The above is the detailed content of What data type is uint16?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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