C++ Standard Library C++ STL Library

C++ <cmath> - float_t Type



The C++ <cmath> float_t type is an alias of one of the fundamental floating-point types at least as wide as float. It is the type used by the implementation to evaluate values of type double, as determined by FLT_EVAL_METHOD.

FLT_EVAL_METHODfloat_tdouble_t
0floatdouble
1doubledouble
2long doublelong double
otherimplementation-definedimplementation-defined

In the <cmath> header file, it is defined as follows:

typedef /* implementation-defined */ float_t;              

Example:

The example below shows the usage of float_t type.

#include <iostream>
#include <cmath>
#include <cfloat>
using namespace std;
 
int main (){

  cout<<"FLT_EVAL_METHOD: "<<FLT_EVAL_METHOD<<"\n";
  cout<<"sizeof(float_t): "<<sizeof(float_t)<<"\n";
  cout<<"sizeof(double_t): "<<sizeof(double_t)<<"\n";
  cout<<"sizeof(float): "<<sizeof(float)<<"\n";
  cout<<"sizeof(double): "<<sizeof(double)<<"\n";
  cout<<"sizeof(long double): "<<sizeof(long double)<<"\n";
  
  return 0;
}

The output of the above code will be:

FLT_EVAL_METHOD: 0
sizeof(float_t): 4
sizeof(double_t): 8
sizeof(float): 4
sizeof(double): 8
sizeof(long double): 16

❮ C++ <cmath> Library