Detailed Java basic data types

Source: Internet
Author: User

    1. BYTE, short, int, long:
      • BYTE takes 8 bits (bit) binary: 0000 0000 and 1111 1111, decimal: -128 < byte < 127
      • Short takes 2 bytes (byte), 16 bits (bit)
      • int is 4 bytes (byte), 32 bit (bit)
      • Long takes 8 bytes, 64 bits (bit)
    2. float, double
      • Float takes 4 bytes, 32 bits
      • Double takes 8 bytes, 64 bits
    3. Char
      • Char takes 2 bytes, 16 bits
    4. Boolean
      • Boolean accounted for 1/8 bytes, 1 bits
calculation table for binary calculator1000 0000 = 1280100 0000 = 640010 0000 = 320001 0000 = 160000 1000 = 80000 0100 = 40000 0010 = 20000 0001 = 10000 0000 = 0
Binary speed algorithm:
    • Take 195 binary?
Ideas:
    1. 195 is greater than 128 so the highest position is 1:1XXX XXXX
    2. 195-128 = 67 is greater than 64 so the highest second bit is calculated as 1:11XX XXXX
    3. 67-64 = 3 is greater than 2 so the projection is: 1100 001X
    4. 3-2 = 1 So the extrapolation is: 1100 0011 is the binary of 195
calculation between basic data types:
    1. The computed result between Byte, short, char is int
    2. int + Long = long
    3. int + float = float
    4. int + double = Double
    5. Any type that is added to string is string

Detailed Java basic data types

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.