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,991評論 19 139
  • 變量就是申請內存來存儲值。也就是說,當創建變量的時候,需要在內存中申請空間。內存管理系統根據變量的類型為變量分配存...
    Roc_J閱讀 599評論 0 1
  • 人生從來沒有真正的絕境。無論遭受多少艱辛,無論經歷多少苦難,只要一個人的心中還懷著一粒信念的種子,那么總有一天,他...
    huang東閱讀 124評論 0 0
  • #日記迎春20170309日行一善 主動提供朋友讀書會場地,請小伙伴配合服務; 跟一位做生涯規劃的朋友通話,聽他介...
    靜儉閱讀 147評論 0 0
  • C2C實際是電子商務的專業用語,是個人與個人之間的電子商務。其中C指的是消費者,因為消費者的英文單詞是Custom...
    黃花菜已涼閱讀 1,040評論 0 3