float, double, long double

Try this code on each of your compilers:

http://ideone.com/cOVGJH

The ideone compiler output is there. Here's my output, with 64-bit clang targeting 64-bit with nuwen MinGW as the backend:
float, double, long double
sizeof = 4, 8, 16
digits = 24, 53, 64
digits10 = 6, 15, 18
max_digits10 = 9, 17, 21
min_exponent10 = -37, -307, -4931
max_exponent10 = 38, 308, 4932
epsilon = 1.19209e-007, 2.22045e-016, 0
min = 1.17549e-038, 2.22507e-308, 0
lowest = -3.40282e+038, -1.79769e+308, 0
max = 3.40282e+038, 1.79769e+308, 0
As you can see, the last four don't seem to be defined for long double, but my long double type is 16 bytes instead of the common 8 or 12, yet it has the same precision as the ideone 12 byte version - I assume this is because it uses the same type as the ideone 12-byte version but has to align to 64 bits rather than 32 bits.

This is with nuwen MinGW by itself:
float, double, long double
sizeof = 4, 8, 16
digits = 24, 53, 64
digits10 = 6, 15, 18
max_digits10 = 9, 17, 21
min_exponent10 = -37, -307, -4931
max_exponent10 = 38, 308, 4932
epsilon = 1.19209e-007, 2.22045e-016, 1.0842e-019
min = 1.17549e-038, 2.22507e-308, 3.3621e-4932
lowest = -3.40282e+038, -1.79769e+308, -1.18973e+4932
max = 3.40282e+038, 1.79769e+308, 1.18973e+4932
Again we see the 16 byte long double, but this time the last four values are defined...
Last edited on
IBM XLC is boring in that regard:
float, double, long double
sizeof = 4, 8, 8
digits = 24, 53, 53
digits10 = 6, 15, 15
max_digits10 =  missing  missing  missing
min_exponent10 = -37, -307, -307
max_exponent10 = 38, 308, 308
epsilon = 1.19209e-07, 2.22045e-16, 2.22045e-16
min = 1.17549e-38, 2.22507e-308, 2.22507e-308
lowest =  missing  missing  missing
max = 3.40282e+38, 1.79769e+308, 1.79769e+308


Sun Studio is more fun:
float, double, long double
sizeof = 4, 8, 16
digits = 24, 53, 113
digits10 = 6, 15, 33
max_digits10 =  missing  missing  missing
min_exponent10 = -37, -307, -4931
max_exponent10 = 38, 308, 4932
epsilon = 1.19209e-07, 2.22045e-16, 1.92593e-34
min = 1.17549e-38, 2.22507e-308, 3.3621e-4932
lowest =  missing  missing  missing
max = 3.40282e+38, 1.79769e+308, inf


and for Linux (64bit) compilers

clang++/libc++ and g++ and intel give the same exact
float, double, long double
sizeof = 4, 8, 16
digits = 24, 53, 64
digits10 = 6, 15, 18
max_digits10 = 9, 17, 21
min_exponent10 = -37, -307, -4931
max_exponent10 = 38, 308, 4932
epsilon = 1.19209e-07, 2.22045e-16, 1.0842e-19
min = 1.17549e-38, 2.22507e-308, 3.3621e-4932
lowest = -3.40282e+38, -1.79769e+308, -1.18973e+4932
max = 3.40282e+38, 1.79769e+308, 1.18973e+4932
Last edited on
MinGW 32-bit gets it right
float, double, long double
sizeof = 4, 8, 12
digits = 24, 53, 64
digits10 = 6, 15, 18
max_digits10 = 9, 17, 21
min_exponent10 = -37, -307, -4931
max_exponent10 = 38, 308, 4932
epsilon = 1.19209e-007, 2.22045e-016, 1.0842e-019
min = 1.17549e-038, 2.22507e-308, 3.3621e-4932
lowest = -3.40282e+038, -1.79769e+308, -1.18973e+4932
max = 3.40282e+038, 1.79769e+308, 1.18973e+4932

AFAIK, VC++ (VS2012) cannot be made to behave with respect to long doubles*:
float, double, long double
sizeof = 4, 8, 8
digits = 24, 53, 53
digits10 = 6, 15, 15
max_digits10 = 9, 17, 17
min_exponent10 = -37, -307, -307
max_exponent10 = 38, 308, 308
epsilon = 1.19209e-007, 2.22045e-016, 2.22045e-016
min = 1.17549e-038, 2.22507e-308, 2.22507e-308
lowest = -3.40282e+038, -1.79769e+308, -1.79769e+308
max = 3.40282e+038, 1.79769e+308, 1.79769e+308

*http://msdn.microsoft.com/en-us/library/9cx8xs15.aspx
Last edited on
Topic archived. No new replies allowed.