java 新增基本数据类型_Java基本数据类型及底层

1.double 双精度浮点数、64 位、其数据结构如下:

e01d605815817384412589026c9369a2.png

1位 | 11位 | 52位

----|------|----

符号位 | 指数位 | 小数位

0表示正,1表示负 |-1024~+1023 | 0.(0-2^51-1)

tip:计算机指数写法 2e10,表示数学上的2*10^(10),而e在数学上也是个特定的数值(这真是计算机这边脑子有坑),在大学刚自学搞代码的时候懵了一段时间直到我发现计算机e表示10^;

2.float 单精度浮点数、32 位、其数据结构如下:

a007b205a934f21691115242fbc89e0b.png

1位 | 8位 | 23位

----|------|----

符号位 | 指数位 | 小数位

0表示正,1表示负 |-128~+127 | 0.(0-2^22-1)

3.long 长整型,64位,其数据结构如下:

1位 | 63位

----|------

符号位 | 数值位

0正,1负 |-2^64- 2^63-1

4.int 整型,32位,其数据结构如下:

1位 | 31位

----|------

符号位 | 数值位

0正,1负 |-2^32 - 2^31-1

5.short 短整型,16位,其数据结构如下:

1位 | 15位

----|------

符号位 | 数值位

0正,1负 |-2^15 - 2^15-1

6.char 字符型,16 位 ,Unicode 字符;

7.byte 字节型,8位,其数据结构如下:

1位 | 7位

----|----

符号位 | 数值位

0正,1负 |-2^7 - 2^71

8.boolean 布尔型

表示一位的信息;只有两个取值:true 和 false;

占用内存大小不确定(单个boolean b 32bit,boolean [] bs 中的item 站8bit 来自1.7 JVM规范)

>Although the java virtual machine defines a boolean type,it only provides very limited support for it.There are no Java virtual machine instructions solely dedicated to operations on boolean values.  Instead, expressions in the java programming language that operate on boolean values are compiled to use values of the java virtual machine int data type.

>The java virtual machine does directly support boolean arrays. Its new array instruction enables creation of boolean arrays. Arrays of type boolean are accessed and modified using the byte array instruction baload and bastore .

>In oracle java virtual machine implementation, boolean arrays in the java programming languae are encoded as java virtual machine byte arrays, using 8 bits per boolean element .

>The java virtual machine encodes boolean array components using 1 to represent true and 0 to represent false . Where java programming language boolean values are mapped by compilers to values of java virtual machine type int , the compilers must use the same encoding.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值