为什么微软放弃长双倍数据类型? [英] Why did Microsoft abandon long double data type?

查看:118
本文介绍了为什么微软放弃长双倍数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前面我写了一个程序,使用一些阶乘函数。我使用long double数据类型来支持相对大数字。

A while ago I wrote a program which used some factorial functions. I used the long double data type to support "relative" big numbers.

现在,我从codeblocks改为Visualstudio 2010,我想知道为什么我的程序没有工作,直到我意识到一些研究后,MS已经放弃了长双数据类型。
有什么特别的原因吗?对我来说,它看起来非常像在技术方面倒退。

Now, I changed from codeblocks to Visualstudio 2010, I was wondering why my program didn't work any more till I realized after some research that MS has abandonded the long double data type. Is there any special reason for this? To me it looks very like step backwards in terms of technology.

有任何其他选择吗? (我也会很高兴与boost库中的替代品)。

Is there any alternative to use? (I would also be happy with an alternative out of the boost library).

推荐答案

我不知道为什么你认为 long double 被放弃,因为它是C ++标准的一部分,因此合规实现必须实现它。

I'm not sure why you think that long double was "abandoned", as it is part of the C++ Standard and therefore a compliant implementation must, well, implement it.

他们做了什么放弃是 long double 数学函数的重载,因为:

What they did "abandon" is long double overloads of mathematical functions, and they did this because:


在Win32编程中, long double 数据类型映射到 double ,64位精度数据类型

In Win32 programming, however, the long double data type maps to the double, 64-bit precision data type.

其中, long double 为80位元,是因为


FP代码生成已切换到使用SSE / SSE2 / SSE3指令集而不是x87 FP堆栈因为这是AMD和英特尔最近和未来的芯片代都聚焦他们的表现努力。这些指令集只支持32位和64位FP格式。

FP code generation has been switching to the use of SSE/SSE2/SSE3 instruction sets instead of the x87 FP stack since that is what both the AMD and Intel recent and future chip generations are focusing their performance efforts on. These instruction sets only support 32 and 64 bit FP formats.

不过,他们选择不支持这些重载,大小 double long double 类型(两者都可以是64位),是一个耻辱, em>也是C ++标准的一部分。但是,好吧,这是微软为你。非常固执。

Still, that they chose not to support these overloads, even with same-sized double and long double types (both could have been made 64-bit), is a shame because they are also part of the C++ Standard. But, well, that's Microsoft for you. Intently stubborn.


[n3290:26.8]: c $ c>添加 float c $ c> double 版本的
函数 / code>和 long double 重载
这些函数的版本,具有相同的语义。

[n3290: 26.8]: In addition to the double versions of the math functions in <cmath>, C++ adds float and long double overloaded versions of these functions, with the same semantics.

但是,虽然这些重载在Visual Studio中基本上已被弃用,但仍然可以使用 ,所以您仍然可以使用它们:

However, although these overloads are essentially deprecated in Visual Studio, they are still available, so you should still be able to use them:


Microsoft运行时库提供
math函数的 long double 版本兼容性。








(我也会很高兴与boost库的替代)。

Is there any alternative to use? (I would also be happy with an alternative out of the boost library).

这听起来像我一样, code> long double 以支持特定范围的数值,因此在不同工具链中发生变化时会遇到回归问题。

It sounds to me like you have been relying on long double to support a specific range of numeric values, and have consequently run into regression issues when that has changed in a different toolchain.

如果您有特定的数值范围要求,请使用固定范围的积分类型。这里有几个选项:

If you have a specific numeric range requirement, use fixed-range integral types. Here you have a few options:


  • stdint.h 一些C ++工具链支持作为扩展;

  • stdint.h - Boost重新实现为库的C99功能; li>
  • cstdint - 如果您正在编写C ++ 0x代码,可能会使用的C ++ 0x功能。 b $ b
  • stdint.h - a C99 feature that some C++ toolchains support as an extension;
  • stdint.h - a C99 feature that Boost re-implements as a library;
  • cstdint - a C++0x feature that may be of use if you are writing C++0x code.

这篇关于为什么微软放弃长双倍数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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