Java Basic Data Type range

Source: Internet
Author: User

Java basic data type range because it is binary storage 1 bytes is 8 bits first is the sign bit 0 is a non-negative 1 negative negative value is the inverse code +1 anti-code: (1 Change 0 0 to 1 sign bit unchanged)

The complement is designed to:

⑴ allows the symbolic potential energy to participate in the operation with the valid Values section, simplifying the operation rules.

⑵ the subtraction operation into addition, further simplifying the circuit design of the computing device in the computer

BYTE 1 byte 8-bit maximum 0 1111 111 = 1+2+4+8+16 +32+64---> 127 min 1 0000 000 = Inverse Code (1 1111 111) (This One is-127) +1=1 0000 000 (because the sign bit is also counted as a value) =-128

Others do not need more explanation:

Short

    • The short data type is a 16-bit, signed integer with a binary complement representation
    • The minimum value is -32768 ( -2^15);
    • The maximum value is 32767 (2^15-1);
    • The short data type can also save space as Byte. A short variable is one-second of the space occupied by the int variable;
    • The default value is 0;
    • Example: Short s = 1000,short r =-20000.

Int:

    • The int data type is a 32-bit, signed integer with a binary complement representation;
    • The minimum value is -2,147,483,648 ( -2^31);
    • The maximum value is 2,147,483,647 (2^31-1);
    • The generic integer variable defaults to the int type;
    • The default value is 0;
    • Example: int a = 100000, int b =-200000.

Long

    • The Long data type is a 64-bit, signed integer with a binary complement representation;
    • The minimum value is -9,223,372,036,854,775,808 ( -2^63);
    • The maximum value is 9,223,372,036,854,775,807 (2^63-1);
    • This type is mainly used on systems that need to compare large integers;
    • The default value is 0L;
    • Example: Long a = 100000l,long B = -200000l.
      "L" is theoretically not case-sensitive, but if written "L" is easily confused with the number "1", it is not easy to distinguish. So it's best to capitalize.

Float

    • The float data type is a single-precision, 32-bit, IEEE 754 compliant floating-point number;
    • Float saves memory space when storing large floating-point groups;
    • The default value is 0.0f;
    • Floating-point numbers cannot be used to denote precise values, such as currency;
    • Example: float f1 = 234.5f.

Double

    • The double data type is a dual-precision, 64-bit, IEEE 754-compliant floating-point number;
    • The default type of floating-point number is double type;
    • A double type cannot also represent an exact value, such as a currency;
    • The default value is 0.0d;
    • Example: Double D1 = 123.4.

Boolean

    • The Boolean data type represents one bit of information;
    • Only two values: true and false;
    • This type is only used as a sign to record the true/false situation;
    • The default value is false;
    • Example: Boolean one = True.

Char

      • The char type is a single 16-bit Unicode character;
      • The minimum value is \u0000 (that is, 0);
      • The maximum value is \uffff (that is, 65,535);
      • Char data type can store any character;
      • Example: char letter = ' A ';.

Java Basic Data Type 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.