float, double, long double

Discussion in 'C++' started by JKop, Aug 7, 2004.

  1. JKop

    JKop Guest

    Does the Standard specify any minimum range or minimum
    precision for the float, double and long double. I haven't
    found anything in the Standard about it.

    -JKop
    JKop, Aug 7, 2004
    #1
    1. Advertising

  2. > Does the Standard specify any minimum range or minimum
    > precision for the float, double and long double. I haven't
    > found anything in the Standard about it.


    Yes: Float must offer at least the equivalent of 6 decimal digits of
    precision; double and long double must offer at least the equivalent of 10
    digits.

    In practice, virtually all implementations use the machine's native
    floating-point types; on most machines today those offer approximately 6
    digits for float and 16 digits for double. Implementations are less
    consistent for long double, but double is good enough for most applications
    anyway.
    Andrew Koenig, Aug 7, 2004
    #2
    1. Advertising

  3. JKop

    Fraser Ross Guest

    "Andrew Koenig"
    > In practice, virtually all implementations use the machine's native
    > floating-point types; on most machines today those offer approximately 6
    > digits for float and 16 digits for double.


    Borland C++ documents have always stated 7 for float and 15 for double.

    Fraser.
    Fraser Ross, Aug 8, 2004
    #3
  4. JKop

    Jack Klein Guest

    On Sat, 07 Aug 2004 20:14:05 GMT, JKop <> wrote in
    comp.lang.c++:

    >
    > Does the Standard specify any minimum range or minimum
    > precision for the float, double and long double. I haven't
    > found anything in the Standard about it.
    >
    > -JKop


    This is one of those cases where the C++ standard adopts the
    requirements of the C standard without repeating the text.

    Section 5.2.4.2 Numerical limits spells out the minimum ranges for all
    integer and floating point types, and minimum precision and several
    other important factors for the floating point types. An
    implementation, C or C++, is required to document its implementation.

    The section number is the same in both the older version of the C
    standard which the C++ standard includes, and the current C standard.

    --
    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++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
    Jack Klein, Aug 8, 2004
    #4
  5. JKop

    JKop Guest

    Jack Klein posted:

    > This is one of those cases where the C++ standard adopts the
    > requirements of the C standard without repeating the text.
    >
    > Section 5.2.4.2 Numerical limits spells out the minimum ranges for all
    > integer and floating point types, and minimum precision and several
    > other important factors for the floating point types. An
    > implementation, C or C++, is required to document its implementation.
    >
    > The section number is the same in both the older version of the C
    > standard which the C++ standard includes, and the current C standard.



    Great! Now all I need is the C Standard. What ever happened to self-
    sufficency, self-containment?


    -JKop
    JKop, Aug 8, 2004
    #5
    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. Sydex
    Replies:
    12
    Views:
    6,445
    Victor Bazarov
    Feb 17, 2005
  2. bd
    Replies:
    0
    Views:
    602
  3. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    654
    Eric Sosman
    Jul 8, 2003
  4. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,172
    Peter Shaggy Haywood
    Sep 20, 2005
  5. Carsten Fuchs
    Replies:
    45
    Views:
    1,501
    James Kanze
    Oct 8, 2009
Loading...

Share This Page