floats doubles long doubles

J

Jack Klein

Can someone tell me the difference between these three data types?

Thanks

Daniel

There may no be any.

The C++ language inherits these floating point types from C. C and
C++ allow, but does not require, three different floating point types.

Each floating point type has certain minimum specifications that it
must meet.

A 32 bit IEEE single precision representation fully meets the
requirements of a float in C and C++, and is what almost all platforms
and compilers use today. It does not meet the requirements for the
wider types.

A 64 bit IEEE double precision representation fully meets the
requirements of both double and long double in C and C++. This is
what almost all platforms and compilers use today for double.

Some hardware architectures (example, Intel x86) provide hardware
support for even higher precision, such as the Intel FPU 80 bit
extended precision format. Some hardware platforms do not.

Even on platforms where there is hardware support for long double to
have more precision than double, there is no requirement for a
compiler to support it. The requirements for double and long double
in C and C++ are identical.

For example, Microsoft 32 bit compilers for x86 do not support the 80
bit extended precision format, although their older 16 bit compilers
did. So double and long double are exactly the same representation in
Visual C++ programs. On the other hand, other compilers for the same
processors such as Borland and GCC do use the 80 bit format, so long
double has more precision and range than double.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top