什么是80位扩展精度数据类型的应用程序/好处? [英] What are the applications/benefits of an 80-bit extended precision data type?

查看:293
本文介绍了什么是80位扩展精度数据类型的应用程序/好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我的意思是说80位。这不是一个错字...



我对浮点变量的经验总是涉及4个字节的倍数,如单数(32位),双精度(64位)和长双打(我见过的是96位或128位)。这就是为什么当我遇到 80位扩展精度数据类型时,我有点困惑,而我正在研究一些代码来读写 AIFF(音频交换文件格式)文件:一个扩展精确的变量被选择来存储音轨的采样率。

当我浏览维基百科时,我发现上面的链接以及80位格式在 IEEE 754-1985标准汇总(但不在 IEEE 754-2008标准摘要)。看起来在某些体系结构中,extended和long double是同义词。

有一点我没有遇到的是使用扩展精度数据的特定应用程序类型(当然,AIFF文件采样率除外)。这引起了我的疑惑:


  • 有没有人遇到过扩展精度对某些编程应用程序是必要/有益的情况?

  • 80位浮点数有什么好处,除了明显的比double长度的大多数实现更精确, b $ b
  • 其适用性是否降低?


解决方案

bit格式,以获得更高精度的中间结果。

也就是说,你可能有32位或64位的变量,但是当它们加载到FPU寄存器,它们被转换成80位;然后FPU(默认)执行80中的所有计算,但是;在计算之后,结果被存回32位或64位的变量。

顺便说一句,这样做的一个不幸的后果是调试和发布版本可能会产生稍微不同的结果:在发布版本中,优化器可能会在80位FPU寄存器中保留一个中间变量,而在调试版本中,它将存储在64位变量中,从而导致精度损失。您可以通过使用80位变量避免这种情况,或使用FPU开关(或编译器选项)以64位执行所有计算。


Yeah, I meant to say 80-bit. That's not a typo...

My experience with floating point variables has always involved 4-byte multiples, like singles (32 bit), doubles (64 bit), and long doubles (which I've seen refered to as either 96-bit or 128-bit). That's why I was a bit confused when I came across an 80-bit extended precision data type while I was working on some code to read and write to AIFF (Audio Interchange File Format) files: an extended precision variable was chosen to store the sampling rate of the audio track.

When I skimmed through Wikipedia, I found the link above along with a brief mention of 80-bit formats in the IEEE 754-1985 standard summary (but not in the IEEE 754-2008 standard summary). It appears that on certain architectures "extended" and "long double" are synonymous.

One thing I haven't come across are specific applications that make use of extended precision data types (except for, of course, AIFF file sampling rates). This led me to wonder:

  • Has anyone come across a situation where extended precision was necessary/beneficial for some programming application?
  • What are the benefits of an 80-bit floating point number, other than the obvious "it's a little more precision than a double but fewer bytes than most implementations of a long double"?
  • Is its applicability waning?

解决方案

Intel's FPUs use the 80-bit format internally to get more precision for intermediate results.

That is, you may have 32-bit or 64-bit variables, but when they are loaded into the FPU registers, they are converted to 80 bit; the FPU then (by default) performs all calculations in 80 but; after the calculation, the result is stored back into a 32-bit or 64-bit variables.

BTW - A somewhat unfortunate consequence of this is that debug and release builds may produce slightly different results: in the release build, the optimizer may keep an intermediate variable in an 80-bit FPU register, while in the debug build, it will be stored in a 64-bit variable, causing loss of precision. You can avoid this by using 80-bit variables, or use an FPU switch (or compiler option) to perform all calculations in 64 bit.

这篇关于什么是80位扩展精度数据类型的应用程序/好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆