long double的取值范围是多少?

najiushifeng1111 2011-04-07 09:04:01
long double占用多少字节?取值范围和精度都是多少,要精确。
...全文
1491 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
luciferisnotsatan 2011-04-08
  • 打赏
  • 举报
回复
有效位是10字节。为了对齐,会作为12字节或者16字节。

long double结构
1个符号位,15个指数位,64个尾数位。
赵4老师 2011-04-08
  • 打赏
  • 举报
回复
C:\Program Files\Microsoft Visual Studio 8\VC\crt\src\float.h
#define DBL_DIG         15                      /* # of decimal digits of precision */
#define DBL_EPSILON 2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */
#define DBL_MANT_DIG 53 /* # of bits in mantissa */
#define DBL_MAX 1.7976931348623158e+308 /* max value */
#define DBL_MAX_10_EXP 308 /* max decimal exponent */
#define DBL_MAX_EXP 1024 /* max binary exponent */
#define DBL_MIN 2.2250738585072014e-308 /* min positive value */
#define DBL_MIN_10_EXP (-307) /* min decimal exponent */
#define DBL_MIN_EXP (-1021) /* min binary exponent */
#define _DBL_RADIX 2 /* exponent radix */
#define _DBL_ROUNDS 1 /* addition rounding: near */
赵4老师 2011-04-08
  • 打赏
  • 举报
回复
C:\Program Files\Microsoft Visual Studio 8\VC\crt\src\float.h
……
#define LDBL_DIG DBL_DIG /* # of decimal digits of precision */
#define LDBL_EPSILON DBL_EPSILON /* smallest such that 1.0+LDBL_EPSILON != 1.0 */
#define LDBL_MANT_DIG DBL_MANT_DIG /* # of bits in mantissa */
#define LDBL_MAX DBL_MAX /* max value */
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP /* max decimal exponent */
#define LDBL_MAX_EXP DBL_MAX_EXP /* max binary exponent */
#define LDBL_MIN DBL_MIN /* min positive value */
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP /* min decimal exponent */
#define LDBL_MIN_EXP DBL_MIN_EXP /* min binary exponent */
#define _LDBL_RADIX DBL_RADIX /* exponent radix */
#define _LDBL_ROUNDS DBL_ROUNDS /* addition rounding: near */
……
AnYidan 2011-04-08
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 supermegaboy 的回复:]
字节数可以通过sizeof( long double )获得,取值范围从float.h头文件中取。
[/Quote]

++
SuperFC 2011-04-07
  • 打赏
  • 举报
回复
对于不同平台可能有不同的实现。有的是8字节,有的是10字节,有的是12字节或更多。好像以前16位的VC++中long double用10字节,而Win32就改用了8字节
飞天御剑流 2011-04-07
  • 打赏
  • 举报
回复
字节数可以通过sizeof( long double )获得,取值范围从float.h头文件中取。
太乙 2011-04-07
  • 打赏
  • 举报
回复
实际使用10字节,但是表示时,32位机器上是12字节,64位机器上是16字节

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧