What is the range of long double in C++?
It is system (and processor, and compiler, and ABI) dependent. Look into <limits.h> and <math.h> and <float.h> standard headers. Show activity on this post. According to MSDN - Data Type Ranges (C++) and the www.cplusplus.com, the long double is the same as double, takes 8 bytes of space and lies in the range [-1.7E+308, 1.7E+308].
For example, in some compiler implementations, double and long double are the same size with the same range of values, while in other implementations, long double is wider and has a broader range of values than double. The standard does not define any unsigned floating-point data types.
The definition of long double is compiler & platform dependent, it is at least the same as a double, thus, it may take 8, 12 (usually also for 80bits) or even 16 bytes ( float128/quadruple precision) and has a range according to its size. Show activity on this post. Use std::numeric_limits to find out. Show activity on this post.
Data types, and their size and range, play an important role in C programming. The sizeof () operator gives the number of bytes required to store a value in memory of a specific form. However, to prevent overflow and underflow errors in programming, we must be aware of a type's range.
#include <limits>
std::numeric_limits<long double>::min()
//...
std::numeric_limits<long double>::max()
The definition of long double
is compiler & platform dependent, it is at least the same as a double
, thus, it may take 8, 12 (usually also for 80bits) or even 16 bytes (float128/quadruple precision) and has a range according to its size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With