admin管理员组文章数量:1130349
大家好,今天来介绍浮点型的表示范围
C++中浮点型分为float,double和long double型,float.h中定义:
//the following are the minimum number of significant digits
#define DBL_DIG 15 //double
#define FLT_DIG 6 //float
#define LDBL_DIG 18 //long double
即float最少可表示6位小数,double最少可表示15位小数,long double最少可表示18位小数。
下面来贴一个例子来说明一下:
#include<iostream>
int main()
{
using namespace std;
cout.setf(ios_base::fixed, ios_base::floatfield); //fixed-point 大家好,今天来介绍浮点型的表示范围
C++中浮点型分为float,double和long double型,float.h中定义:
//the following are the minimum number of significant digits
#define DBL_DIG 15 //double
#define FLT_DIG 6 //float
#define LDBL_DIG 18 //long double
即float最少可表示6位小数,double最少可表示15位小数,long double最少可表示18位小数。
下面来贴一个例子来说明一下:
#include<iostream>
int main()
{
using namespace std;
cout.setf(ios_base::fixed, ios_base::floatfield); //fixed-point 版权声明:本文标题:C++入门——浮点数表示范围注意事项 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/jiaocheng/1754940383a2744189.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论