码迷,mamicode.com
首页 > 编程语言 > 详细

Java Primitives and Bits

时间:2017-04-20 19:40:03      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:types   use   utf-8   ica   writing   ascii   utf-16   unicode   double   

技术分享

Integer

when processors were 16 bit, an int was 2 bytes. Nowadays, it‘s most often 4 bytes on a 32 bits system or 8 bytes on 64 bits system.

Character

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

  • An ISO-8895-1 character in ISO-8859-1 encoding is 8 bits (1 byte).

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

Java uses unicode system. Character in the java class file is encoded with UTF-8 while running in JVM is encoded with UTF-16.

Long & Double

Writing longs and doubles is not atomic in Java.

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

Java‘s primitive types are guaranteed to be a particular length across all machines. On some 64 bits JVMs nowadays, the operations of longs and doubles are effectively atomic.

 

Java Primitives and Bits

标签:types   use   utf-8   ica   writing   ascii   utf-16   unicode   double   

原文地址:http://www.cnblogs.com/codingforum/p/6740260.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!