float, double, long double

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JKop

    float, double, long double


    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
  • Andrew Koenig

    #2
    Re: float, double, long double

    > Does the Standard specify any minimum range or minimum[color=blue]
    > precision for the float, double and long double. I haven't
    > found anything in the Standard about it.[/color]

    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.


    Comment

    • Fraser Ross

      #3
      Re: float, double, long double


      "Andrew Koenig"[color=blue]
      > 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.[/color]

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

      Fraser.


      Comment

      • Jack Klein

        #4
        Re: float, double, long double

        On Sat, 07 Aug 2004 20:14:05 GMT, JKop <NULL@NULL.NULL > wrote in
        comp.lang.c++:
        [color=blue]
        >
        > 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[/color]

        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.l earn.c-c++

        Comment

        • JKop

          #5
          Re: float, double, long double

          Jack Klein posted:
          [color=blue]
          > 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.[/color]


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


          -JKop

          Comment

          Working...