Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's bigger than a double?

Is there a native c++ variable type that's "bigger" than a double?
float is 7
double is 15 (of course depending on the compiler)
Is there anything bigger that's native, or even non-native?

like image 824
baash05 Avatar asked Nov 02 '08 20:11

baash05


People also ask

What is larger than a double?

Type long double is a floating point type that is larger than or equal to type double . Microsoft-specific: The representation of long double and double is identical. However, long double and double are treated as distinct types by the compiler.

What's bigger than a double C++?

C++ has long double , but there is no guarantee that it's any more precise than a plain double . On an x86 platform, usually double is 64 bits, and long double is either 64 or 80 bits (which gives you 19 significant figures, if I remember right).

What's bigger double or long?

In an article on MSDN, it states that the double data type has a range of "-1.79769313486232e308 .. 1.79769313486232e308". Whereas the long data type only has a range of "-9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807".

Who is bigger double or float?

A float has 7 decimal digits of precision and occupies 32 bits . A double is a 64-bit IEEE 754 double-precision floating-point number. 1 bit for the sign, 11 bits for the exponent, and 52 bits for the value. A double has 15 decimal digits of precision and occupies a total of 64 bits .


2 Answers

C++ has long double, but there is no guarantee that it's any more precise than a plain double. On an x86 platform, usually double is 64 bits, and long double is either 64 or 80 bits (which gives you 19 significant figures, if I remember right).

Your mileage may vary, especially if you're not on x86.

like image 188
Chris Jester-Young Avatar answered Sep 21 '22 08:09

Chris Jester-Young


A long double typically only uses 10 bytes, but due to alignment may actually take up 12 or 16 (depending on the compiler and options) bytes in a structure.

The 10 byte long double provides a 64-bit mantissa; this is very convenient for when you want to store 64 bit integers in floating point without loss of precision.

like image 33
ysth Avatar answered Sep 20 '22 08:09

ysth