什么是float和double的C和C ++的大小? [英] What is the size of float and double in C and C++?

查看:227
本文介绍了什么是float和double的C和C ++的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找,看看是否有标准型类似于 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.

这篇关于什么是float和double的C和C ++的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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