Are long doubles a rare species?

I've noticed that not many people use the long double data type. On some environments it's the same as a double, but in others it has more precision (on one I tested it was 12 bytes in size). Is there a reason that just plain double gets used instead of long double? Or is it just less commonly known?
Last edited on
Perhaps because of this?
On some environments it's the same as a double, but in others it has more precision


Why take up more space in the program, while also affecting the consistency of answers?
Normally you won't find yourself needing long double data types.
Mats wrote:
Perhaps because of this?
> On some environments it's the same as a double, but in others it has more precision

Why take up more space in the program, while also affecting the consistency of answers?
The same could be said about the relationship of double to float.
Last edited on
The same could be said about the relationship of double to float.


And are floats not more common than doubles? ;)
Considering so many sources teach you not to use the "float" data type because of how imprecise it is, I'd day that floats are less common.
It depends entirely on context. Float is typically precise enough to do what you want.

A lot of modern hardware has doubles, and defaults to using them internally. Double is a natural choice in that case.

x86 systems have had, for a long time, the 'extended' data type, which (IIRC) was more-or-less recently ratified as an IEEE standard type. Also, IIRC, x86 systems use extended for internal calculations. If your compiler supports it, long double is the same as the extended type. (But your compiler may not, alas, and not bother to tell you.)

The reason for higher-precision floating point types is typically driven by need. For example, scientific applications like they use at the observatory will typically want to use something with better precision than 'float'. For graphics applications like the next first-person shooter won't need the precision, but may use double anyway because of profiled performance issues.

Hope this helps.
Topic archived. No new replies allowed.