Java byte value range

Source: Internet
Author: User

Tag: Represents a byte size positive number inverse code style review binary

The value range of Java Byte we all know (-128 ~ 127), then-128 and 127 How are the two numbers calculated?

#大学知识回顾:

Concept: The complement of a negative number is the absolute value of the original code bitwise negation, and then the entire number plus 1

There are 3 representations of the fixed-point number in the computer: original code, inverse code, and complement

The [original code] is the binary fixed-point notation described earlier, that is, the highest bit is the sign bit, "0" is positive, "1" is negative, and the remaining bits represent the size of the value.

[Anti-code] notation: The inverse of a positive number is the same as its original code; the inverse of a negative number is a bitwise negation of its original code, except for the sign bit.

The [complement] notation stipulates that the complement of positive numbers is the same as the original code, and the complement of negative numbers is added to the minus 1 of the inverse code.

Java uses the complement to represent the binary number, in the complement representation, the highest bit is the sign bit, the positive sign bit is 0, the negative number is 1.

Now for the Java Byte Value range analysis:

1. Determine that byte is 1 bytes, or 8 bits

2, for the computer, the binary maximum positive number is 01111111 converted to decimal: 127

3, the smallest negative number: 10000000, that is-128

Binary negative value: Take the inverse plus one, so the value of 10000000 is:
1. Reverse-01111111 127
2. Add a - 128
3. Plus symbol: -128




Java byte value range

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.