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

java中的浮點(diǎn)數(shù)和雙精度數(shù)有多少位有效數(shù)字?

How many significant digits do floats and doubles have in java?(java中的浮點(diǎn)數(shù)和雙精度數(shù)有多少位有效數(shù)字?)
本文介紹了java中的浮點(diǎn)數(shù)和雙精度數(shù)有多少位有效數(shù)字?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

浮點(diǎn)數(shù)有 32 位二進(jìn)制數(shù),雙精度數(shù)有 64 位二進(jìn)制數(shù)嗎?文檔太難理解了.

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

所有位都轉(zhuǎn)換為有效數(shù)字嗎?還是小數(shù)點(diǎn)的位置占用了一些位?

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用于尾數(shù)(大約 7 個(gè)十進(jìn)制數(shù)字).8 位用于指數(shù),因此浮點(diǎn)數(shù)可以使用這 8 位將小數(shù)點(diǎn)向右或向左移動(dòng)".這樣做可以避免在尾數(shù)中存儲(chǔ)大量零,如 0.0000003 (3 × 10-7) 或 3000000 (3 × 107).有 1 位用作符號(hào)位.

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 字節(jié)),其中 52 位 用于尾數(shù)(大約 16 位十進(jìn)制數(shù)字).11位用于指數(shù),1位為符號(hào)位.

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.

由于我們使用二進(jìn)制(只有 0 和 1),所以當(dāng)數(shù)字非零時(shí),尾數(shù)中的一位隱含為 1(浮點(diǎn)數(shù)和雙精度數(shù)都使用此技巧).

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.

此外,由于所有內(nèi)容都是二進(jìn)制(尾數(shù)和指數(shù)),因此轉(zhuǎn)換為十進(jìn)制數(shù)通常不準(zhǔn)確.像 0.5、0.25、0.75、0.125 這樣的數(shù)字被精確存儲(chǔ),但 0.1 不是.正如其他人所說(shuō),如果您需要精確存儲(chǔ)美分,請(qǐng)不要使用 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.

來(lái)源:

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

這篇關(guān)于java中的浮點(diǎn)數(shù)和雙精度數(shù)有多少位有效數(shù)字?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周?chē)h(huán)繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動(dòng)生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數(shù)據(jù)庫(kù))
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對(duì)象?)
Use threading to process file chunk by chunk(使用線(xiàn)程逐塊處理文件)
主站蜘蛛池模板: 黄色录像免费观看 | 欧美激情视频一区 | a毛片视频 | 国产综合视频 | 成人免费高清视频 | 欧美一级做性受免费大片免费 | 日韩视频第一页 | 久视频在线 | 91性高潮久久久久久久久 | 福利视频网站 | 欧美午夜精品久久久久免费视 | 国产精品伦子伦免费视频 | 午夜视频在线播放 | 成人福利 | 日韩成人免费 | 亚洲精选一区 | 91av在线免费观看 | 国产伦精品一区二区三毛 | 天天操网 | 成年人视频网站 | 操操操av | 国产成人免费在线视频 | 日韩欧美色图 | 色窝| 日韩三级中文字幕 | 国产一级黄色录像 | 中文字幕高清在线 | a视频在线免费观看 | 欧美精品一二区 | 欧美另类小说 | 日韩av免费播放 | 精品一区三区 | 久久精品视频一区二区 | 在线观看二区 | 欧美黄色一级视频 | 九色网址 | 国产aa视频 | 国产成人福利 | 亚洲毛片网 | 欧美性生交xxxxx | 日日夜夜av|