floats doubles long doubles

Discussion in 'C++' started by dan, Nov 26, 2003.

  1. dan

    dan Guest

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

    Thanks

    Daniel
    dan, Nov 26, 2003
    #1
    1. Advertising

  2. dan

    Jack Klein Guest

    On 25 Nov 2003 20:19:44 -0800, (dan) wrote in
    comp.lang.c++:

    > 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
    Jack Klein, Nov 26, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. {AGUT2} {H}-IWIK
    Replies:
    4
    Views:
    2,835
    Marcelo Pinto
    Sep 12, 2003
  2. J.K. Becker
    Replies:
    43
    Views:
    981
  3. Chris N. Hinds

    unions with long long ints and doubles?

    Chris N. Hinds, Sep 30, 2003, in forum: C Programming
    Replies:
    3
    Views:
    410
    Barry Schwarz
    Oct 2, 2003
  4. SpreadTooThin
    Replies:
    7
    Views:
    398
    Diez B. Roggisch
    Sep 16, 2006
  5. Andrew Reilly

    Re: Floats, doubles C and MSVC

    Andrew Reilly, Oct 14, 2004, in forum: C Programming
    Replies:
    2
    Views:
    661
    Tim Prince
    Oct 14, 2004
Loading...

Share This Page