久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

java中的浮點數和雙精度數有多少位有效數字?

How many significant digits do floats and doubles have in java?(java中的浮點數和雙精度數有多少位有效數字?)
本文介紹了java中的浮點數和雙精度數有多少位有效數字?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

浮點數有 32 位二進制數,雙精度數有 64 位二進制數嗎?文檔太難理解了.

Does a float have 32 binary digits and a double have 64 binary digits? The documentation was too hard to make sense of.

所有位都轉換為有效數字嗎?還是小數點的位置占用了一些位?

Do all of the bits translate to significant digits? Or does the location of the decimal point take up some of the bits?

推薦答案

float: 32 bits (4 bytes) 其中23 bits用于尾數(大約 7 個十進制數字).8 位用于指數,因此浮點數可以使用這 8 位將小數點向右或向左移動".這樣做可以避免在尾數中存儲大量零,如 0.0000003 (3 × 10-7) 或 3000000 (3 × 107).有 1 位用作符號位.

float: 32 bits (4 bytes) where 23 bits are used for the mantissa (about 7 decimal digits). 8 bits are used for the exponent, so a float can "move" the decimal point to the right or to the left using those 8 bits. Doing so avoids storing lots of zeros in the mantissa as in 0.0000003 (3 × 10-7) or 3000000 (3 × 107). There is 1 bit used as the sign bit.

double:64 位(8 字節),其中 52 位 用于尾數(大約 16 位十進制數字).11位用于指數,1位為符號位.

double: 64 bits (8 bytes) where 52 bits are used for the mantissa (about 16 decimal digits). 11 bits are used for the exponent and 1 bit is the sign bit.

由于我們使用二進制(只有 0 和 1),所以當數字非零時,尾數中的一位隱含為 1(浮點數和雙精度數都使用此技巧).

Since we are using binary (only 0 and 1), one bit in the mantissa is implicitly 1 (both float and double use this trick) when the number is non-zero.

此外,由于所有內容都是二進制(尾數和指數),因此轉換為十進制數通常不準確.像 0.5、0.25、0.75、0.125 這樣的數字被精確存儲,但 0.1 不是.正如其他人所說,如果您需要精確存儲美分,請不要使用 float 或 double,使用 int、long、BigInteger 或 BigDecimal.

Also, since everything is in binary (mantissa and exponents) the conversions to decimal numbers are usually not exact. Numbers like 0.5, 0.25, 0.75, 0.125 are stored exactly, but 0.1 is not. As others have said, if you need to store cents precisely, do not use float or double, use int, long, BigInteger or BigDecimal.

來源:

http://en.wikipedia.org/wiki/Floating_point#IEEE_754:_floating_point_in_modern_computers

http://en.wikipedia.org/wiki/Binary64

http://en.wikipedia.org/wiki/Binary32

這篇關于java中的浮點數和雙精度數有多少位有效數字?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: av乱码 | 中文字幕免费视频 | 午夜电影网站 | 国产一区二区久久 | 性色视频在线观看 | 国产91在线 | 欧美 | 久久久久国产一区二区三区四区 | 国产伦精品一区二区三区精品视频 | 夜夜爽99久久国产综合精品女不卡 | 亚洲女优在线播放 | 综合网中文字幕 | 成人夜晚看av | 欧美日韩亚洲在线 | 日本激情视频中文字幕 | 夜夜操av | 一区二区三区四区在线视频 | 午夜天堂精品久久久久 | 午夜视频一区二区 | 久久草在线视频 | 91久久精品一区二区二区 | 日操操 | 欧美一级久久久猛烈a大片 日韩av免费在线观看 | 日日拍夜夜| 91久久夜色 | 国产一区二区三区在线视频 | 日本一区二区不卡视频 | 黄色国产 | 激情三区 | 欧美精品久久久久久久久久 | 亚洲美女天堂网 | 成人欧美一区二区三区 | 国产成人啪免费观看软件 | 婷婷色国产偷v国产偷v小说 | 欧洲妇女成人淫片aaa视频 | 最新免费视频 | 久久久91精品国产一区二区三区 | 国产区视频在线观看 | 99久久精品国产一区二区三区 | 午夜免费成人 | 另类视频区 | 亚洲黄色av网站 |