What uncommon floating-point sizes exist in C++ compilers?

后端 未结 3 525
谎友^
谎友^ 2021-01-14 17:59

The C++14 draft standard seems rather quiet about the specific requirements for float, double and long double, although these sizes seem to be common:

3条回答
  •  春和景丽
    2021-01-14 18:44

    First of, I am new to stackoverflow, so please bear with me.

    However, to answer your question. Looking at the floath.h headers, which specify floating point parameters for the:

    1. Intel Compiler

      //Float:
      #define FLT_MAX                 3.40282347e+38F
      
      //Double:
      #define DBL_MAX                 1.7976931348623157e+308
      
      //Long Double:
      #if (__IMFLONGDOUBLE == 64) || defined(__LONGDOUBLE_AS_DOUBLE)
      #define LDBL_MAX                    1.7976931348623157e+308L
      #else
      #define LDBL_MAX                1.1897314953572317650213E+4932L
      
    2. GCC (MinGW actually gcc 4 or 5)

      //Float:
      #define FLT_MAX         3.40282347e+38F
      
      //Double:
      #define DBL_MAX     1.7976931348623157e+308
      
      //Long Double: (same as double for gcc):
      #define LDBL_MAX        1.7976931348623157e+308L
      
    3. Microsoft

      //Float:
      #define FLT_MAX         3.40282347e+38F
      
      //Double:
      #define DBL_MAX     1.7976931348623157e+308
      
      //Long Double: (same as double for Microsoft):
      #define LDBL_MAX            DBL_MAX
      

    So, as you can see only the Intel compiler provides 80 bit representation for long double on a "standard" windows machine.

    This data is copied from the respective float.h headers from a windows machine.

提交回复
热议问题