耳塞戴久了有什么危害| 肾结石可以吃什么| 血氧仪是干什么用的| 口干口苦口臭是什么原因| 健康证是什么样的| 陪嫁一般陪些什么东西| 无味是什么意思| 小孩子流鼻血是什么原因引起的| 低密度脂蛋白胆固醇偏高是什么意思| pt是什么金属| 腰椎退行性改变是什么意思| 梦见生孩子是什么意思解梦| 四季豆为什么叫四季豆| 苦瓜干泡水喝有什么功效| 大白条是什么鱼| 火鸡面为什么那么辣| 咽炎要注意什么饮食| 独一无二是什么生肖| 表述是什么意思| 排卵期出血是什么样的| 北阳台适合种什么植物| 女人什么时候最想要| 土字生肖有钱收是什么生肖| 什么解辣| 亚硝酸盐阴性是什么意思| 血常规一般查什么病| 一条什么| 人生格言是什么| 巴基斯坦人说什么语言| 全脂牛奶是什么意思| 智能手环是干什么用的| 属蛇与什么属相相克| 静脉曲张挂号挂什么科| 疱疹性咽峡炎用什么药| 1997年是什么命| baumwolle是什么面料| 鸡蛋液是什么| 蛇为什么怕雄黄| 百岁山和景田什么关系| 梦到怀孕生孩子是什么意思| 乐不思蜀什么意思| 兔爷是什么意思| 蛇喜欢吃什么| 眼睛一直眨是什么原因| 吃什么减肥效果最好最快| oba是什么意思| 医美是什么| 睾丸长什么样子| 为什么头皮会疼| 经期头疼是什么原因怎么办| 六月八号什么星座| 宫颈转化区三型是什么意思| 最快的速度是什么| 水晶为什么要消磁| 鸡头米是什么| 线性骨折是什么意思| 垂涎欲滴意思是什么| 倒模是什么| 什么是个体工商户| 熟女是什么意思| 美国为什么不敢动朝鲜| 为什么不能摸猫的肚子| 尿隐血阳性是什么意思| 跑团是什么| p.a.是什么意思| 清道夫鱼为什么不能吃| 降调是什么意思| 咽喉炎吃什么药管用| 三月初九是什么星座| 1955年属什么| 小腿酸胀痛是什么原因| 右肺上叶为什么恶性多| 甲状腺是什么科| 精子是什么味道| 看静脉曲张挂什么科| 925银和s925银有什么区别| 人流后可以吃什么| 阴到炎用什么药好得快| 阻生智齿是什么意思| 什么姓氏排第一| 什么是耦合| 望眼欲穿是什么意思| 什么是芡实| 硫酸亚铁是什么颜色| 巨蟹座男和什么座最配对| 痛什么什么痛| 二脚趾比大脚趾长代表什么| 十月十四是什么星座| 对戒是什么意思| 印度尼西亚是什么人种| live什么意思| 回锅肉是什么肉| 甲硝唑有什么副作用| 私处瘙痒用什么药| 公主是什么意思| 男生一般什么时候停止长高| 胃火吃什么食物好| 什么布料| o发什么音| 一件代发是什么意思| 杨枝甘露是什么做的| 右手麻木是什么病| 头顶爱出汗是什么原因| 科级干部是什么级别| 舌苔白有齿痕吃什么药| 湛江有什么好玩的| rov是什么意思| 形婚是什么意思啊| 脾虚是什么原因导致的| hpv和tct有什么区别| 立夏吃什么蛋| 农历5月17日是什么星座| 吃什么补孕酮最快| 当兵有什么要求| 人皇是什么意思| 28岁属什么的| 梅毒是什么| 什么病不能吃空心菜| 什么的果子| 乳腺结节不能吃什么| 喝酒后胃不舒服吃什么药| 逆来顺受什么意思| 报复是什么意思| 什么是肺部腺性肿瘤| 周期性是什么意思| 面基是什么意思啊| 甲胎蛋白高是什么原因| 南京区委书记什么级别| 屁为什么是臭的| 满族八大碗都有什么菜| 澳门使用什么货币| 梦见黄鼠狼是什么意思| 右边小腹疼是什么原因女性| 柔五行属什么| 梦见蛇是什么意思| 国防部是干什么的| 梦见割草是什么意思| 中规中矩什么意思| 比目鱼又叫什么鱼| 金蝉脱壳什么意思| toryburch什么牌子| 干贝是什么东西做的| 扩词是什么| 违法是什么意思| 呼吸不顺畅是什么原因| 兵戎相见是什么意思| 沙茶酱做什么菜最好吃| 颈椎病吃什么药效果好| 玛卡是什么| 泰坦尼克号女主角叫什么| 什么是肠易激综合征| 天哭星是什么意思| 车前草有什么功效和作用| 左下腹疼是什么原因| 耳耵聍是什么东西| 手指缝脱皮是什么原因| 人为什么会咳嗽| 后天是什么意思| 了凡四训讲的是什么| 桑树叶有什么功效| 集分宝是什么意思| 交界痣是什么| 魑魅魍魉是什么意思| 梦见黑色的蛇是什么意思| 乌鸡蛋是什么颜色| 什么水晶招财旺事业| 04年出生属什么| 循序渐进是什么意思| 满城尽带黄金甲是什么意思| 畸胎瘤是什么病| 兴风作浪什么意思| 肝有钙化灶是什么意思| 什么是心律不齐| 打喷嚏流鼻涕属于什么感冒| 高血压什么症状表现| 君子菜是什么蔬菜| 排卵试纸什么时候测最准| 荨麻疹吃什么| 看肺结节挂什么科| 清蒸什么鱼好吃| 朗格手表什么档次| 女人左手掌有痣代表什么| eric是什么意思| 龙的本命佛是什么佛| 舒五行属什么| 感冒流清水鼻涕吃什么药| 皮肤一块块白是什么病| 痤疮用什么药| 可爱是什么意思| 乔迁送什么| 什么叫乳糖不耐受| 绚丽夺目的意思是什么| 脚臭是什么原因| 属狗的幸运色是什么颜色| 高锰酸钾在药店叫什么| 南京有什么好玩的景点| 泉州和晋江什么关系| 胃痛吃什么| 孕妇便秘吃什么最快排便| 蓝精灵是什么药| 秀恩爱是什么意思| 10月28日什么星座| 什么东西辟邪| 什么魂什么魄| 八月十二是什么星座| 螃蟹过街的歇后语是什么| 辣椒是什么科| 吃什么补雌激素最快| 2000属什么生肖| 山楂什么季节成熟| 胃萎缩是什么意思| 寂静的意思是什么| 枫叶什么颜色| 棒槌是什么意思| 脚麻是什么原因造成的| 肌红蛋白高是什么原因| 红枣为什么要去核煮| 白带黄什么原因| 赝品是什么意思| 梅干菜是什么菜做的| 黄的什么| 什么叫桑黄| 胸部ct可以检查出什么| 蚊子喜欢咬什么人| 莲子不能和什么一起吃| 沙蟹吃什么| 为什么日语怎么说| 低钾血症挂什么科| 耽美什么意思| 尿多尿频是什么原因造成的| 洗劫一空是什么意思| 风凉话是什么意思| 低热是什么症状| 一什么铃铛| 红细胞平均体积偏低是什么意思| kms是什么意思| 稽留流产是什么意思| 天秤女喜欢什么样的男生| 远山含黛是什么意思| 夏天吃什么水果| 乙肝25阳性什么意思| 什么是回迁房| 早上口干苦是什么原因| 渎神是什么意思| 为什么不呢| 指标是什么意思| 日久见人心是什么意思| mup是什么意思| 什么是猝死| 七月份有什么节日吗| 12月9号是什么星座| 氨咖黄敏胶囊主治什么| 胸闷心慌是什么病| 康普茶是什么| 年柱将星是什么意思| 低血压吃什么| 来大姨妈吃什么对身体好| 淋巴结炎吃什么药| 孩子打呼噜是什么原因| 9月15号是什么日子| 分分钟都妙不可言是什么歌| 肛门疼痛是什么原因引起的| 急性肠胃炎可以吃什么食物| 游击战是什么意思| 百度

张家界航空职院在机械行业职业院校技能大赛中

(Redirected from Single precision float)
百度 “当时我还在卖槟榔,我的师傅曾勇就告诉我,一定要有一个团队,有团队才会壮大。

Single-precision floating-point format (sometimes called FP32 or float32) is a computer number format, usually occupying 32 bits in computer memory; it represents a wide dynamic range of numeric values by using a floating radix point.

A floating-point variable can represent a wider range of numbers than a fixed-point variable of the same bit width at the cost of precision. A signed 32-bit integer variable has a maximum value of 231 ? 1 = 2,147,483,647, whereas an IEEE 754 32-bit base-2 floating-point variable has a maximum value of (2 ? 2?23) × 2127 ≈ 3.4028235 × 1038. All integers with seven or fewer decimal digits, and any 2n for a whole number ?149 ≤ n ≤ 127, can be converted exactly into an IEEE 754 single-precision floating-point value.

In the IEEE 754 standard, the 32-bit base-2 format is officially referred to as binary32; it was called single in IEEE 754-1985. IEEE 754 specifies additional floating-point types, such as 64-bit base-2 double precision and, more recently, base-10 representations.

One of the first programming languages to provide single- and double-precision floating-point data types was Fortran. Before the widespread adoption of IEEE 754-1985, the representation and properties of floating-point data types depended on the computer manufacturer and computer model, and upon decisions made by programming-language designers. E.g., GW-BASIC's single-precision data type was the 32-bit MBF floating-point format.

Single precision is termed REAL(4) or REAL*4 in Fortran;[1] SINGLE-FLOAT in Common Lisp;[2] float binary(p) with p≤21, float decimal(p) with the maximum value of p depending on whether the DFP (IEEE 754 DFP) attribute applies, in PL/I; float in C with IEEE 754 support, C++ (if it is in C), C# and Java;[3] Float in Haskell[4] and Swift;[5] and Single in Object Pascal (Delphi), Visual Basic, and MATLAB. However, float in Python, Ruby, PHP, and OCaml and single in versions of Octave before 3.2 refer to double-precision numbers. In most implementations of PostScript, and some embedded systems, the only supported precision is single.

IEEE 754 standard: binary32

edit

The IEEE 754 standard specifies a binary32 as having:

This gives from 6 to 9 significant decimal digits precision. If a decimal string with at most 6 significant digits is converted to the IEEE 754 single-precision format, giving a normal number, and then converted back to a decimal string with the same number of digits, the final result should match the original string. If an IEEE 754 single-precision number is converted to a decimal string with at least 9 significant digits, and then converted back to single-precision representation, the final result must match the original number.[6]

The sign bit determines the sign of the number, which is the sign of the significand as well. "1" stands for negative. The exponent field is an 8-bit unsigned integer from 0 to 255, in biased form: a value of 127 represents the actual exponent zero. Exponents range from ?126 to +127 (thus 1 to 254 in the exponent field), because the biased exponent values 0 (all 0s) and 255 (all 1s) are reserved for special numbers (subnormal numbers, signed zeros, infinities, and NaNs).

The true significand of normal numbers includes 23 fraction bits to the right of the binary point and an implicit leading bit (to the left of the binary point) with value 1. Subnormal numbers and zeros (which are the floating-point numbers smaller in magnitude than the least positive normal number) are represented with the biased exponent value 0, giving the implicit leading bit the value 0. Thus only 23 fraction bits of the significand appear in the memory format, but the total precision is 24 bits (equivalent to log10(224) ≈ 7.225 decimal digits) for normal values; subnormals have gracefully degrading precision down to 1 bit for the smallest non-zero value.

The bits are laid out as follows:

 

The real value assumed by a given 32-bit binary32 data with a given sign, biased exponent E (the 8-bit unsigned integer), and a 23-bit fraction is

 ,

which yields

 

In this example:

  •  ,
  •  ,
  •  ,
  •  ,
  •  .

thus:

  •  .

Note:

  •  ,
  •  ,
  •  ,
  •  .

Exponent encoding

edit

The single-precision binary floating-point exponent is encoded using an offset-binary representation, with the zero offset being 127; also known as exponent bias in the IEEE 754 standard.

  • Emin = 01H?7FH = ?126
  • Emax = FEH?7FH = 127
  • Exponent bias = 7FH = 127

Thus, in order to get the true exponent as defined by the offset-binary representation, the offset of 127 has to be subtracted from the stored exponent.

The stored exponents 00H and FFH are interpreted specially.

Exponent fraction = 0 fraction ≠ 0 Equation
00H = 000000002 ±zero subnormal number  
01H, ..., FEH = 000000012, ..., 111111102 normal value  
FFH = 111111112 ±infinity NaN (quiet, signaling)

The minimum positive normal value is   and the minimum positive (subnormal) value is  .

Converting decimal to binary32

edit

In general, refer to the IEEE 754 standard itself for the strict conversion (including the rounding behaviour) of a real number into its equivalent binary32 format.

Here we can show how to convert a base-10 real number into an IEEE 754 binary32 format using the following outline:

  • Consider a real number with an integer and a fraction part such as 12.375
  • Convert and normalize the integer part into binary
  • Convert the fraction part using the following technique as shown here
  • Add the two results and adjust them to produce a proper final conversion

Conversion of the fractional part: Consider 0.375, the fractional part of 12.375. To convert it into a binary fraction, multiply the fraction by 2, take the integer part and repeat with the new fraction by 2 until a fraction of zero is found or until the precision limit is reached which is 23 fraction digits for IEEE 754 binary32 format.

 , the integer part represents the binary fraction digit. Re-multiply 0.750 by 2 to proceed
 
 , fraction = 0.011, terminate

We see that   can be exactly represented in binary as  . Not all decimal fractions can be represented in a finite digit binary fraction. For example, decimal 0.1 cannot be represented in binary exactly, only approximated. Therefore:

 

Since IEEE 754 binary32 format requires real values to be represented in   format (see Normalized number, Denormalized number), 1100.011 is shifted to the right by 3 digits to become  

Finally we can see that:  

From which we deduce:

  • The exponent is 3 (and in the biased form it is therefore  )
  • The fraction is 100011 (looking to the right of the binary point)

From these we can form the resulting 32-bit IEEE 754 binary32 format representation of 12.375:

 

Note: consider converting 68.123 into IEEE 754 binary32 format: Using the above procedure you expect to get   with the last 4 bits being 1001. However, due to the default rounding behaviour of IEEE 754 format, what you get is  , whose last 4 bits are 1010.

Example 1: Consider decimal 1. We can see that:  

From which we deduce:

  • The exponent is 0 (and in the biased form it is therefore  
  • The fraction is 0 (looking to the right of the binary point in 1.0 is all  )

From these we can form the resulting 32-bit IEEE 754 binary32 format representation of real number 1:

 

Example 2: Consider a value 0.25. We can see that:  

From which we deduce:

  • The exponent is ?2 (and in the biased form it is  )
  • The fraction is 0 (looking to the right of binary point in 1.0 is all zeroes)

From these we can form the resulting 32-bit IEEE 754 binary32 format representation of real number 0.25:

 

Example 3: Consider a value of 0.375. We saw that  

Hence after determining a representation of 0.375 as   we can proceed as above:

  • The exponent is ?2 (and in the biased form it is  )
  • The fraction is 1 (looking to the right of binary point in 1.1 is a single  )

From these we can form the resulting 32-bit IEEE 754 binary32 format representation of real number 0.375:

 

Converting binary32 to decimal

edit

If the binary32 value, 41C80000 in this example, is in hexadecimal we first convert it to binary:

 

then we break it down into three parts: sign bit, exponent, and significand.

  • Sign bit:  
  • Exponent:  
  • Significand:  

We then add the implicit 24th bit to the significand:

  • Significand:  

and decode the exponent value by subtracting 127:

  • Raw exponent:  
  • Decoded exponent:  

Each of the 24 bits of the significand (including the implicit 24th bit), bit 23 to bit 0, represents a value, starting at 1 and halves for each bit, as follows:

bit 23 = 1
bit 22 = 0.5
bit 21 = 0.25
bit 20 = 0.125
bit 19 = 0.0625
bit 18 = 0.03125
bit 17 = 0.015625
.
.
bit 6 = 0.00000762939453125
bit 5 = 0.000003814697265625
bit 4 = 0.0000019073486328125
bit 3 = 0.00000095367431640625
bit 2 = 0.000000476837158203125
bit 1 = 0.0000002384185791015625
bit 0 = 0.00000011920928955078125

The significand in this example has three bits set: bit 23, bit 22, and bit 19. We can now decode the significand by adding the values represented by these bits.

  • Decoded significand:  

Then we need to multiply with the base, 2, to the power of the exponent, to get the final result:

 

Thus

 

This is equivalent to:

 

where s is the sign bit, x is the exponent, and m is the significand.

Precision limitations on decimal values (between 1 and 16777216)

edit
  • Decimals between 1 and 2: fixed interval 2?23 (1+2?23 is the next largest float after 1)
  • Decimals between 2 and 4: fixed interval 2?22
  • Decimals between 4 and 8: fixed interval 2?21
  • ...
  • Decimals between 2n and 2n+1: fixed interval 2n?23
  • ...
  • Decimals between 222=4194304 and 223=8388608: fixed interval 2?1=0.5
  • Decimals between 223=8388608 and 224=16777216: fixed interval 20=1

Precision limitations on integer values

edit
  • Integers between 0 and 16777216 can be exactly represented (also applies for negative integers between ?16777216 and 0)
  • Integers between 224=16777216 and 225=33554432 round to a multiple of 2 (even number)
  • Integers between 225 and 226 round to a multiple of 4
  • ...
  • Integers between 2n and 2n+1 round to a multiple of 2n?23
  • ...
  • Integers between 2127 and 2128 round to a multiple of 2104
  • Integers greater than or equal to 2128 are rounded to "infinity".

Notable single-precision cases

edit

These examples are given in bit representation, in hexadecimal and binary, of the floating-point value. This includes the sign, (biased) exponent, and significand.

0 00000000 000000000000000000000012 = 0000 000116 = 2?126 × 2?23 = 2?149 ≈ 1.4012984643 × 10?45
                                      (smallest positive subnormal number)

0 00000000 111111111111111111111112 = 007f ffff16 = 2?126 × (1 ? 2?23) ≈ 1.1754942107 ×10?38
                                      (largest subnormal number)

0 00000001 000000000000000000000002 = 0080 000016 = 2?126 ≈ 1.1754943508 × 10?38
                                      (smallest positive normal number)

0 11111110 111111111111111111111112 = 7f7f ffff16 = 2127 × (2 ? 2?23) ≈ 3.4028234664 × 1038
                                      (largest normal number)

0 01111110 111111111111111111111112 = 3f7f ffff16 = 1 ? 2?24 ≈ 0.999999940395355225
                                      (largest number less than one)

0 01111111 000000000000000000000002 = 3f80 000016 = 1 (one)

0 01111111 000000000000000000000012 = 3f80 000116 = 1 + 2?23 ≈ 1.00000011920928955
                                      (smallest number larger than one)

1 10000000 000000000000000000000002 = c000 000016 = ?2
0 00000000 000000000000000000000002 = 0000 000016 = 0
1 00000000 000000000000000000000002 = 8000 000016 = ?0

0 11111111 000000000000000000000002 = 7f80 000016 = infinity
1 11111111 000000000000000000000002 = ff80 000016 = ?infinity

0 10000000 100100100001111110110112 = 4049 0fdb16 ≈ 3.14159274101257324 ≈ π (pi)
0 01111101 010101010101010101010112 = 3eaa aaab16 ≈ 0.333333343267440796 ≈ 1/3

x 11111111 100000000000000000000012 = ffc0 000116 = qNaN (on x86 and ARM processors)
x 11111111 000000000000000000000012 = ff80 000116 = sNaN (on x86 and ARM processors)

By default, 1/3 rounds up, instead of down like double-precision, because of the even number of bits in the significand. The bits of 1/3 beyond the rounding point are 1010... which is more than 1/2 of a unit in the last place.

Encodings of qNaN and sNaN are not specified in IEEE 754 and implemented differently on different processors. The x86 family and the ARM family processors use the most significant bit of the significand field to indicate a quiet NaN. The PA-RISC processors use the bit to indicate a signaling NaN.

Optimizations

edit

The design of floating-point format allows various optimisations, resulting from the easy generation of a base-2 logarithm approximation from an integer view of the raw bit pattern. Integer arithmetic and bit-shifting can yield an approximation to reciprocal square root (fast inverse square root), commonly required in computer graphics.

See also

edit

References

edit
  1. ^ "REAL Statement". scc.ustc.edu.cn. Archived from the original on 2025-08-07. Retrieved 2025-08-07.
  2. ^ "CLHS: Type SHORT-FLOAT, SINGLE-FLOAT, DOUBLE-FLOAT..." www.lispworks.com.
  3. ^ "Primitive Data Types". Java Documentation.
  4. ^ "6 Predefined Types and Classes". haskell.org. 20 July 2010.
  5. ^ "Float". Apple Developer Documentation.
  6. ^ William Kahan (1 October 1997). "Lecture Notes on the Status of IEEE Standard 754 for Binary Floating-Point Arithmetic" (PDF). p. 4. Archived from the original (PDF) on 8 February 2012.
edit
染色体是什么意思 千卡是什么意思 因特网是什么意思 你喜欢我什么我改 心血管堵塞吃什么药
尿道口流脓什么病 摧残是什么意思 成人受到惊吓吃什么药 白斑不能吃什么 儿童补钙吃什么
不作为是什么意思 临床表现是什么意思 河水像什么 针灸是什么 站桩对身体有什么好处和功效
脑梗会有什么后遗症 养膘是什么意思 收缩压偏高是什么意思 今年28岁属什么生肖 祠堂是什么意思
灰指甲什么样hcv8jop9ns3r.cn 心火旺吃什么药效果最好gangsutong.com 后腰出汗多是什么原因hcv8jop8ns6r.cn 什么老什么老hcv8jop6ns0r.cn 宫内囊性回声代表什么hcv9jop7ns2r.cn
在家无聊可以做什么hcv7jop6ns1r.cn 1998年属什么生肖hcv9jop1ns1r.cn 专业术语是什么意思hcv9jop1ns2r.cn 3月3日是什么节hcv9jop3ns3r.cn 左手虎口有痣代表什么hcv8jop9ns6r.cn
开背鱼是什么鱼hcv9jop7ns4r.cn 脚麻是什么原因造成的hcv8jop8ns0r.cn 五彩的什么hcv8jop2ns7r.cn 初级会计考什么科目hcv9jop0ns1r.cn 肌肉劳损吃什么药hcv8jop3ns8r.cn
鳄鱼的天敌是什么动物hcv8jop5ns6r.cn 排尿困难是什么原因男性hcv9jop7ns9r.cn 小孩手足口病吃什么食物好hcv8jop9ns7r.cn 白身是什么意思hcv8jop9ns6r.cn 应该说什么cj623037.com
百度