Java Primitives and Bits

Source: Internet
Author: User

Integer

When processors were-bit, an int is 2 bytes. Nowadays, it's most often the 4 bytes on a 8 bits system or the bytes on the "bits system."

Character
    • An ASCII character in 8-bit ASCII encoding is 8 bits (1 bytes), though it can fit in 7 bits.

    • An iso-8895-1 character in iso-8859-1 encoding is 8 bits (1 bytes).

    • A Unicode character in UTF-8 encoding is between 8 bits (1 bytes) and A. Bits (4 bytes).

Java uses Unicode system. Character in the Java class file was encoded with UTF-8 while running in JVM was encoded with UTF-16.

Long & Double

Writing longs and doubles are not atomic in Java.

It ' s not atomic because it's a multiple-step operation at the machine code level. That's, longs and doubles is longer than the processor ' s word length. Doubles and longs is not read or written to atomically unless they ' re declaredvolatile.

Java's primitive types is guaranteed to is a particular length across all machines. On some-JVMs nowadays, the operations of longs and doubles are effectively atomic.

Java Primitives and Bits

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.