性能影响长双倍.为什么C选择默认的是64位而不是硬件的80位? [英] Performance implications of long double. Why does C choose 64-bits instead of the hardware's 80-bit for its default?

查看:92
本文介绍了性能影响长双倍.为什么C选择默认的是64位而不是硬件的80位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具体来说,我谈论的是x87 PC架构和C编译器.

For specifics I am talking about x87 PC architecture and the C compiler.

我正在编写自己的解释器,而double数据类型背后的推理使我感到困惑.特别是在效率方面.有人可以解释为什么C选择了64位double而不是硬件本机的80位double吗?以及为什么硬件没有设置在80位的double上,因为它没有对齐?每种性能都有什么影响? 我想使用80位的double作为默认数字类型.但是编译器开发人员的选择让我担心,这不是最佳选择.

I am writing my own interpreter and the reasoning behind the double datatype confuses me. Especially where efficiency is concerned. Could someone explain WHY C has decided on a 64-bit double and not the hardware native 80-bit double? And why has the hardware settled on an 80-bit double, since that is not aligned? What are the performance implications of each? I would like to use an 80-bit double for my default numeric type. But the choices of the compiler developers make me concerned that this is not the best choice.

    x86上的
  1. double仅短2个字节,为什么编译器默认不使用10个字节的long double?
  2. 我能否举一个80位long doubledouble相比获得的额外精度的例子?
  3. Microsoft为什么默认情况下禁用long double ?
  4. 就幅度而言,典型的x86/x64 PC硬件上的long double差多少/慢些?
  1. double on x86 is only 2 bytes shorter, why doesn't the compiler use the 10 byte long double by default?
  2. Can I get an example of the extra precision gotten by 80-bit long double vs double?
  3. Why does Microsoft disable long double by default?
  4. In terms of magnitude, how much worse / slower is long double on typical x86/x64 PC hardware?

推荐答案

根据Mysticial的回答,微软将 SSE2 用于其double数据类型.与现代CPU扩展相比,浮点单元(FPU)x87被视为过时且较慢. SSE2不支持80位,因此编译器选择64位精度.

The answer, according to Mysticial, is that Microsoft uses SSE2 for its double data-type. The Floating point unit (FPU) x87 is seen as outdated and slow in comparison to modern CPU extensions. SSE2 does not support 80-bit, hence the compiler's choice of 64-bit precision.

在32位x86体系结构上,由于所有CPU都还没有SSE2,因此,除非给出了编译器开关/arch:SSE2,否则Microsoft仍将使用浮点单元(FPU)x87.哪个使代码与较旧的代码不兼容? CPU.

On 32-bit x86 architecture, since all CPUs don't have SSE2 yet, Microsoft still uses the floating point unit (FPU) x87 unless the compiler switch /arch:SSE2 is given. Which makes the code incompatible with those older? CPUs.

这篇关于性能影响长双倍.为什么C选择默认的是64位而不是硬件的80位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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