C++入门——浮点数表示范围注意事项

大家好,今天来介绍浮点型的表示范围 C++中浮点型分为float,double和long double型,float.h中定义: the following are the minimum number of significant

大家好,今天来介绍浮点型的表示范围


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  

发布者:admin,转转请注明出处:http://www.yc00.com/web/1754940383a5218043.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信