[LC++]float, double, or long double?

Jack Lloyd lloyd at acm.jhu.edu
Tue Jan 7 00:55:01 UTC 2003


On Mon, 6 Jan 2003, David Spencer wrote:

> The most accurate are the integral forms - int, long, long long etc.
>  All floating point representations are approximate.  double stores more
> digits than float, and I think there's a long double as well, but there
> is no complex type in C (but you can use two doubles.)

IIRC there is a complex type in C99, which GCC does support. In addition,
since this was address to the C++ list, I'll add that there is a complex<T>
class in ISO C++.

On many machines, long double is the same size as double, but on some FPUs
you may get a few extra bits. The x87 is like that, though there are other
problems there (80 bits internally, 64 bits outside the FPU... rather
strange). Also SPARC supports a 128 bit long double, but no hardware
supports it so it just traps into software routines.

The original poster could also try GMP, which, I think, supports infinite
precision floating point. Of course it's much slower since it's all done in
software instead of the FPU.

-Jack




More information about the tuxCPProgramming mailing list