Home > Common Problem > body text

What is the range of 16-bit binary numbers?

青灯夜游
Release: 2020-12-21 12:00:42
Original
60273 people have browsed it

The 16-bit unsigned binary number represents the range from 0 to 65535 (that is, 2 to the 16th power minus 1); the 16-bit signed binary number represents the range from (2 to the 15th power minus 1) plus Positive and negative signs, but computers usually use complement representation, so the range is "-32768" to "32767".

What is the range of 16-bit binary numbers?

Related recommendations: "Programming Video"

The range of integers that can be represented by 16 binary digits

If it is unsigned, it is 0 to 65535 (that is, 2 to the 16th power minus 1)

If it is signed, then the highest bit is used as the sign bit, indicating the range It is (2 to the 15th power - 1) plus a positive and negative sign, which is -32767 to 32767; however, computers usually use complement representation, so when there is a sign, the range is -32768 to 32767.

Detailed description:

All bits of unsigned binary numbers are numerical bits, so positive and negative are not considered. 16-bit binary can represent a total of 2^16 numbers, which is 65536 numbers. The minimum is 0000 0000 0000 0000 and the maximum is 1111 1111 1111 1111, which is 0~65535.

The first bit of a signed binary number is the sign bit, 0 means positive, 1 means negative, and all the remaining bits are numerical bits. The following is divided into original code, complement code and complement code for discussion:

1. In the case of original code, the minimum 16-bit binary number is 1111 1111 1111 1111, and the maximum is 0111 1111 1111 1111, that is, -32767 to 32767 .

2. In the case of inverse code, since the inverse code only inverts the numerical bits of the original code bit by bit and the sign bit remains unchanged, the actual representation range will not change.

3. In the case of two's complement code, since the complement code of 0 is unique, that is, 0000 0000 0000 0000, 1000 0000 0000 0000 does not represent 0, but -32768. Therefore, in the case of two's complement code, the minimum 16-bit binary number is 1000 0000 0000 0000, and the maximum is 0111 1111 1111 1111, which is -32768~32767.

To sum up, the 16-bit unsigned binary number represents the range from 0 to 65535, while the 16-bit signed binary number represents the range from -32768 to 32767 (in the complement case).

What is the range of 16-bit binary numbers?

To read more related articles, please visit PHP Chinese website! !

The above is the detailed content of What is the range of 16-bit binary numbers?. 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