Java基本数据类型

1位 11位 52位
符号位 指数位 小数位
0表示正,1表示负 -1024~+1023 0.(0-2^51-1)

现在简书有BUG,制作一张表格显示两份
1.double 双精度浮点数、64 位、其数据结构如下:


double.png
1位 11位 52位
符号位 指数位 小数位
0表示正,1表示负 -1024~+1023 0.(0-2^51-1)

tip:计算机指数写法 2e10,表示数学上的2*10(10),而e在数学上也是个特定的数值(这真是计算机这边脑子有坑),在大学刚自学搞代码的时候懵了一段时间直到我发现计算机e表示10;
2.float 单精度浮点数、32 位、其数据结构如下:

1位 8位 23位
符号位 指数位 小数位
0表示正,1表示负 -128~+127 0.(0-2^22-1)
float.png
1位 8位 23位
符号位 指数位 小数位
0表示正,1表示负 -128~+127 0.(0-2^22-1)
1位 63位
符号位 数值位
0正,1负 -2^63 - 2^63-1

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

1位 63位
符号位 数值位
0正,1负 -2^63 - 2^63-1
1位 31位
符号位 数值位
0正,1负 -2^31 - 2^31-1

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

1位 31位
符号位 数值位
0正,1负 -2^31 - 2^31-1
1位 15位
符号位 数值位
0正,1负 -2^15 - 2^15-1

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

1位 15位
符号位 数值位
0正,1负 -2^15 - 2^15-1
1位 7位
符号位 数值位
0正,1负 -2^7 - 2^71

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 newarray 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 language 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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,973评论 19 139
  • 变量就是申请内存来存储值。也就是说,当创建变量的时候,需要在内存中申请空间。内存管理系统根据变量的类型为变量分配存...
    Roc_J阅读 599评论 0 1
  • 人生从来没有真正的绝境。无论遭受多少艰辛,无论经历多少苦难,只要一个人的心中还怀着一粒信念的种子,那么总有一天,他...
    huang东阅读 124评论 0 0
  • #日记迎春20170309日行一善 主动提供朋友读书会场地,请小伙伴配合服务; 跟一位做生涯规划的朋友通话,听他介...
    静俭阅读 147评论 0 0
  • C2C实际是电子商务的专业用语,是个人与个人之间的电子商务。其中C指的是消费者,因为消费者的英文单词是Custom...
    黄花菜已凉阅读 1,040评论 0 3