为什么C99标准的作者不为浮点类型的大小指定标准? [英] Why don't the authors of the C99 standard specify a standard for the size of floating point types?

查看:54
本文介绍了为什么C99标准的作者不为浮点类型的大小指定标准?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到在Windows和Linux x86上,float是4字节类型,double是8,但是long double在x86和x86_64上分别是12和16.C99应该打破具有特定整数大小的障碍.

I noticed on Windows and Linux x86, float is a 4-byte type, double is 8, but long double is 12 and 16 on x86 and x86_64 respectively. C99 is supposed to be breaking such barriers with the specific integral sizes.

最初的技术限制似乎是由于x86处理器不能处理80位以上的浮点运算(加上2个字节以进行四舍五入),但是为什么与int类型相比标准不一致?为什么他们至少不进行80位标准化?

The initial technological limitation appears to be due to the x86 processor not being able to handle more than 80-bit floating point operations (plus 2 bytes to round it up) but why the inconsistency in the standard compared to int types? Why don't they go at least to 80-bit standardization?

推荐答案

C语言没有指定各种类型的实现,因此可以在尽可能多的硬件上有效地实现它.

The C language doesn't specify the implementation of various types, so that it can be efficiently implemented on as wide a variety of hardware as possible.

这也扩展到整数类型-C标准整数类型的最小范围(例如, signed char 是-127到127, short int 均为-32,767至32,767, long 为-2,147,483,647至2,147,483,647,而 long long 为-9,223,372,036,854,775,807至9,223,372,036,854,775,807).对于几乎所有目的,这都是程序员需要知道的全部内容.

This extends to the integer types too - the C standard integral types have minimum ranges (eg. signed char is -127 to 127, short and int are both -32,767 to 32,767, long is -2,147,483,647 to 2,147,483,647, and long long is -9,223,372,036,854,775,807 to 9,223,372,036,854,775,807). For almost all purposes, this is all that the programmer needs to know.

C99确实提供了固定宽度"整数类型,例如 int32_t -但是这些是可选-如果实现不能有效地提供这种类型,则不会不必提供它.

C99 does provide "fixed-width" integer types, like int32_t - but these are optional - if the implementation can't provide such a type efficiently, it doesn't have to provide it.

对于浮点类型,存在相同的限制(例如, double 必须具有至少10个十进制数字的精度).

For floating point types, there are equivalent limits (eg double must have at least 10 decimal digits worth of precision).

这篇关于为什么C99标准的作者不为浮点类型的大小指定标准?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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