Java integers account for a few bytes, and the binary representation of negative numbers, and the difference between the logical operators of Java >> and >>>

Source: Internet
Author: User

How many bytes does a Java integer occupy?
A: 4 bytes, a total of 32 bits1 bytes accounted for 8 bits (1B (byte) = 8 bit)Therefore, the type and byte correspond to the following byte1short2
Char 2 int 4Float 4
Double 8double 8----------------------------------------------------------------------- The following is a size output with System.out.println-----------------------------------------------------------

Byte.size //8

Short.size //16
Character.size//16

Integer.size //32
Float.size); //32

Double.size //64
Long.size //64

--------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------

Binary representation of integer negative numbers: in a computer, negative numbers are expressed in the form of a positive complement
complement = inverse code plus 1, negative number is a positive complement

Like 1:00000000000000000000000000000001.

and -1:11111111111111111111111111111111

Maximum value: 01111111111111111111111111111111 2147483647 2 of 31 square minus one

Minimum value : 10000000000000000000000000000000-2147483648 2 of 31-Time Square

--------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------

logical operators of Java >> and >>> differences>> is unsigned right shift>>> is the sign bit right shiftExample:11111111111111111111111111111100:-4
11111111111111111111111111111111: -4>>2-1
00111111111111111111111111111111: -4>>>2 1073741823 

Java integers account for a few bytes, and the binary representation of negative numbers, and the difference between the logical operators of Java >> and >>>

Related Article

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.