为什么在我的64位计算机上double和long double完全相同? [英] Why are double and long double completely the same on my 64 bit machine?

查看:47
本文介绍了为什么在我的64位计算机上double和long double完全相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于初学者来说,这个问题听起来很像,但是当我发现自己以为是初学者或者我的伴侣缺少某些东西时:

This question may sound like for beginners, however when I found that out I thought I'm either a beginner or my comp is missing something:

int main()
{
    cout << sizeof(double) << endl;
    cout << sizeof(long double) << endl;

    cout << DBL_DIG << endl;
    cout << LDBL_DIG << endl;

    return 0;
}

程序输出:

8

8

15

15

我认为 long double 是10个字节,具有18个十进制数字,而 double 是8个字节,具有15个数字,但是似乎我错了.

I thought long double is 10 bytes and has 18 decimal digits while double is 8 bytes and has 15 digits but it seems I was wrong.

为什么会这样?

在64位计算机上使用MSVC 2010.

Using MSVC 2010 on 64bit machine.

推荐答案

在MSVC ++中, long double double 的同义词.显然,这是为了利用仅限于64位操作的SSE/SSE2/SSE3指令集.

In MSVC++, long double is a synonym for double as you've found out. Apparently this is to take advantage of SSE/SSE2/SSE3 instruction sets which are limited to 64-bit operations.

另请参见此处.

这篇关于为什么在我的64位计算机上double和long double完全相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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