c语言打印double类型
问题描述
- 精选答案
-
相信很多人学C语言时, 对long double的印象就是, 它能存储精度比double更高的浮点数.但事实上并不完全是这样.C98的标准是: double类型的值是long double的子集
C++ 98 standard: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.也就是說,long double只是定義為至少跟double一樣精度(即是可以一樣)
在wiki上的long double上找到:
On the x86 architecture, most C compilers implement long doubleas the 80-bit extended precision type supported by x86 hardware (sometimes stored as 12 or 16 bytes to maintain data structure alignment), as specified in the C99 / C11 standards (IEC 60559 floating-point arithmetic (Annex F)).
An exception is Microsoft Visual C++ for x86, which makes long doublea synonym for double.
在MSDN上, 可以发现:
Previous 16-bit versions of Microsoft C/C++ and Microsoft Visual C++ supported the long double, 80-bit precision data type. In Win32 programming, however, the long double data type maps to the double, 64-bit precision data type. The Microsoft run-time library provides long double versions of the math functions only for backward compatibility. The long double function prototypes are identical to the prototypes for their double counterparts, except that thelongdouble data type replaces the double data type. The long doubleversions of these functions should not be used in new code.
早期windows 16位是支持long double类型(80位), 可是在Win32编程中, double跟long double等价了, 都是64位了. 尽管数学函数如sin, cos等仍然保留long double类型,可是这些仅仅用来保持向后兼容(windows为了向后兼容付出了很多的..还有dll地狱一说)也就是说, 在32位中, long double 跟 double等价, 精度也是一样的.
我在自己机器上测试,
cout <<
"sizeof(double) =
" << sizeof(double) << endl;cout <<
"sizeof(long double) =
" << sizeof(long double) << endl;
输出都是8字节(64位)
猜你喜欢内容
-
简单网:构建全网教育数据枢纽,让知识检索化繁为...
简单网:构建全网教育数据枢纽,让知识检索化繁为“简”回答数有0条优质答案参考
-
去三亚有什么好玩的地方
去三亚有什么好玩的地方回答数有1条优质答案参考
-
石狮一日游必去景点推荐
石狮一日游必去景点推荐回答数有1条优质答案参考
-
电气工程师的证书考取条件是什么
电气工程师的证书考取条件是什么回答数有1条优质答案参考
-
房地产估价师的具体报考条件有啥
房地产估价师的具体报考条件有啥回答数有1条优质答案参考
-
房产经纪人的工作内容具体包含什么
房产经纪人的工作内容具体包含什么回答数有1条优质答案参考
-
学习小提琴都有哪些难点
学习小提琴都有哪些难点回答数有1条优质答案参考
-
企业行政管理证书的含金量怎么样
企业行政管理证书的含金量怎么样回答数有1条优质答案参考
-
初学者要怎么入门小提琴
初学者要怎么入门小提琴回答数有1条优质答案参考
-
报考珠宝鉴定师要啥条件
报考珠宝鉴定师要啥条件回答数有1条优质答案参考
















