什么是float和double的C和C ++的大小?大小、float、double

由网友(一群土鳖土鳖数星星i)分享简介:我一直在寻找,看看是否有标准型类似于 uint32_t的它总是会映射到一个32位无符号整型,但我无法找到任何I was looking to see if there is any standard type similar to uint32_t which always would map into a 32-b...

我一直在寻找,看看是否有标准型类似于 uint32_t的它总是会映射到一个32位无符号整型,但我无法找到任何

I was looking to see if there is any standard type similar to uint32_t which always would map into a 32-bit unsigned integral type but I could not find any.

浮动所有平台上始终为4个字节的大小? 为的大小双总是8?

Is the size of float always 4 byte on all platform? Is the size of double always 8?

无论是否标准说对此事什么?

Does either standard say anything on the matter?

我想确保我的大小始终是在所有平台(x86和x64),所以我使用标准的int型一样,但我找不到任何类似的typedef 浮动

I want to make sure that my size is always the same on all platforms (x86 and x64) so I am using standard int types, but I could not find any similar typedef for float and double.

推荐答案

不说的大小事情。

3.9.1.8

有三种浮点类型:浮动,双,和长双。   double类型至少提供高达precision为float,以及   类型为long double至少提供高达precision为双。该   集float类型的值是设定值的子集   双类型;设定double类型的值的一个子集   集合类型长双值的。再$ P $的psentation价值   浮点类型是实现定义。整型和浮点   类型被统称算术类型。的专业化   标准模板的std :: numeric_limits的(18.3)应指定最大   每个算术类型的实现的最小值。

There are three floating point types: float, double, and long double. The type double provides at least as much precision as float, and the type long double provides at least as much precision as double. The set of values of the type float is a subset of the set of values of the type double; the set of values of the type double is a subset of the set of values of the type long double. The value representation of floating-point types is implementation-defined. Integral and floating types are collectively called arithmetic types. Specializations of the standard template std::numeric_limits (18.3) shall specify the maximum and minimum values of each arithmetic type for an implementation.

阅读全文

相关推荐

最新文章