大家好,今天来介绍浮点型的表示范围
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条)