long double

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

    long double

    Is this a part of C 99 or just an addon in some windows compilers like
    pellesC ?
  • Ioannis Vranos

    #2
    Re: long double

    broli wrote:
    Is this a part of C 99 or just an addon in some windows compilers like
    pellesC ?
    It has been a part of all C language standards: ISO C90, C95, C99.

    Comment

    • Malcolm McLean

      #3
      Re: long double


      "broli" <Broli00@gmail. comwrote in message news:
      Is this a part of C 99 or just an addon in some windows compilers like
      pellesC ?
      >
      Basically it's a hardware question. Whilst floating point can be emulated in
      software, if you have to do this it's unlikely that you need much precision.
      If the hardware supports 80 bit floats then the C compiler has to support
      them, in practise, or people would complain. I think it is actually part of
      C99, for what it's worth, but that standard hasn't received wide acceptance,
      so it doesn't really matter whether long double is in it or not.

      --
      Free games and programming goodies.


      Comment

      • Philip Potter

        #4
        Re: long double

        Malcolm McLean wrote:
        "broli" <Broli00@gmail. comwrote in message news:
        >Is this a part of C 99 or just an addon in some windows compilers like
        >pellesC ?
        >>
        Basically it's a hardware question. Whilst floating point can be emulated in
        software, if you have to do this it's unlikely that you need much precision.
        If the hardware supports 80 bit floats then the C compiler has to support
        them, in practise, or people would complain. I think it is actually part of
        C99, for what it's worth, but that standard hasn't received wide acceptance,
        so it doesn't really matter whether long double is in it or not.
        You seem to be confused about what 'long double' means. There is no
        requirement that long double be at least 80 bits. Although long double
        is part of C99, it is not guaranteed to be any larger or store any more
        values than double.

        Philip

        Comment

        • jacob navia

          #5
          Re: long double

          broli wrote:
          Is this a part of C 99 or just an addon in some windows compilers like
          pellesC ?
          long double is part of C99

          --
          jacob navia
          jacob at jacob point remcomp point fr
          logiciels/informatique

          Comment

          • jacob navia

            #6
            Re: long double

            Malcolm McLean wrote:
            >
            "broli" <Broli00@gmail. comwrote in message news:
            >Is this a part of C 99 or just an addon in some windows compilers like
            >pellesC ?
            >>
            Basically it's a hardware question.
            No, the question was about the standard. The questions is
            Are "long double"s part of C99?

            There is no hint as to any hardware questions.
            Whilst floating point can be
            emulated in software, if you have to do this it's unlikely that you need
            much precision. If the hardware supports 80 bit floats then the C
            compiler has to support them, in practise, or people would complain.
            No, this is completely wrong. The compiler can IGNORE them and if people
            complain the compiler builders will not give a damm.

            Example at hand: In Microsoft compilers, long double is the same as
            double. The users are complaining since 10 years and they go on.
            I
            think it is actually part of C99, for what it's worth, but that standard
            hasn't received wide acceptance, so it doesn't really matter whether
            long double is in it or not.
            >
            And your opinion about C99 matters even less.

            C99 is the current C standard, even if you persist on trying to
            disqualify it.



            --
            jacob navia
            jacob at jacob point remcomp point fr
            logiciels/informatique

            Comment

            • Keith Thompson

              #7
              Re: long double

              jacob navia <jacob@nospam.c omwrites:
              broli wrote:
              >Is this a part of C 99 or just an addon in some windows compilers like
              >pellesC ?
              >
              long double is part of C99
              Yes. long double is (was?) also part of C89/C90, and I'm reasonably
              sure that the requirements for C90 did not change between C90 and C99.
              C99 did make a minor change in the printf formats for long double, and
              added math functions for long double, but made no change in the type
              itself.

              I don't know where this idea that long double is a C99-specific
              feature came from, but it's mistaken. (I'm not suggesting that jacob
              made this mistake; I'm just providing additional information.)

              --
              Keith Thompson (The_Other_Keit h) <kst-u@mib.org>
              Nokia
              "We must do something. This is something. Therefore, we must do this."
              -- Antony Jay and Jonathan Lynn, "Yes Minister"

              Comment

              • Bartc

                #8
                Re: long double


                "broli" <Broli00@gmail. comwrote in message
                news:eb8adef5-9db8-4440-97e1-c516d35d596e@q2 7g2000prf.googl egroups.com...
                Is this a part of C 99 or just an addon in some windows compilers like
                pellesC ?
                Long double seems to be part of both C90 and C99 standards. And in both it
                seems to be at least 32-bits.

                Whether you get any more precision depends on your compiler, but it may not
                necessarily be more than double.

                --
                Bart


                Comment

                • Eric Sosman

                  #9
                  Re: long double

                  Bartc wrote:
                  "broli" <Broli00@gmail. comwrote in message
                  news:eb8adef5-9db8-4440-97e1-c516d35d596e@q2 7g2000prf.googl egroups.com...
                  >Is this a part of C 99 or just an addon in some windows compilers like
                  >pellesC ?
                  >
                  Long double seems to be part of both C90 and C99 standards.
                  Yes.
                  And in both it
                  seems to be at least 32-bits.
                  This needs some explanation. There must be at least
                  LDBL_DIG * lg(10) bit-equivalents in the fractional part
                  of a long double, and since LDBL_DIG must be at least 10
                  this implies a fraction of at least 33.2+ bit-equivalents.
                  There must also be enough distinct exponent values to cover
                  the range LDBL_MIN_10_EXP through LDBL_MAX_10_EXP , which
                  must be at least the range -37 through +37; 75 or more
                  distinct values implies lg(75) = 6.2+ bit-equivalents.
                  Finally there's the sign, for one more bit-equivalent. All
                  in all, long double needs at least 40.4+ bit-equivalents.

                  Since 40.4+ is "at least 32," you're right.
                  Whether you get any more precision depends on your compiler, but it may not
                  necessarily be more than double.
                  Right: the minimum requirements for long double's range
                  and precision are the same as those for plain double, so the
                  implementation is not obliged to do any better. It must not
                  do any worse, though.

                  --
                  Eric.Sosman@sun .com

                  Comment

                  • Philip Potter

                    #10
                    Re: long double

                    Eric Sosman wrote:
                    Bartc wrote:
                    >"broli" <Broli00@gmail. comwrote in message
                    >news:eb8adef 5-9db8-4440-97e1-c516d35d596e@q2 7g2000prf.googl egroups.com...
                    >>Is this a part of C 99 or just an addon in some windows compilers like
                    >>pellesC ?
                    >Long double seems to be part of both C90 and C99 standards.
                    >
                    Yes.
                    >
                    >And in both it
                    >seems to be at least 32-bits.
                    >
                    This needs some explanation. There must be at least
                    LDBL_DIG * lg(10) bit-equivalents in the fractional part
                    of a long double, and since LDBL_DIG must be at least 10
                    this implies a fraction of at least 33.2+ bit-equivalents.
                    No, you only need (LDBL_DIG * lg(10) - 1) bit-equivalents in binary. In
                    binary floating point, the most significant bit is always 1 except for
                    unnormalised numbers, infinities, NaNs, and zero. The first three aren't
                    required to exist, and the minimum possible value can be defined to be zero.
                    There must also be enough distinct exponent values to cover
                    the range LDBL_MIN_10_EXP through LDBL_MAX_10_EXP , which
                    must be at least the range -37 through +37; 75 or more
                    distinct values implies lg(75) = 6.2+ bit-equivalents.
                    Finally there's the sign, for one more bit-equivalent. All
                    in all, long double needs at least 40.4+ bit-equivalents.
                    >
                    Since 40.4+ is "at least 32," you're right.
                    And hence I think you only need 39.4 bits in binary (and even in other
                    radices, you could probably exploit the fact that the most significant
                    digit is nonzero to reduce the requirement below 40.4 bits).
                    >Whether you get any more precision depends on your compiler, but it may not
                    >necessarily be more than double.
                    >
                    Right: the minimum requirements for long double's range
                    and precision are the same as those for plain double, so the
                    implementation is not obliged to do any better. It must not
                    do any worse, though.
                    Indeed. The set of double values are a subset of long double values.

                    Philip

                    Comment

                    • David Thompson

                      #11
                      Re: long double

                      On Mon, 07 Apr 2008 14:40:55 -0400, Eric Sosman <Eric.Sosman@su n.com>
                      wrote:
                      Bartc wrote:
                      <snip[long double] seems to be at least 32-bits.
                      >
                      This needs some explanation. There must be at least
                      LDBL_DIG * lg(10) bit-equivalents in the fractional part
                      of a long double, and since LDBL_DIG must be at least 10
                      this implies a fraction of at least 33.2+ bit-equivalents.
                      Possibly minus 1 for hidden-bit, as already discussed.
                      There must also be enough distinct exponent values to cover
                      the range LDBL_MIN_10_EXP through LDBL_MAX_10_EXP , which
                      must be at least the range -37 through +37; 75 or more
                      distinct values implies lg(75) = 6.2+ bit-equivalents.
                      There is no need for the exponent's base to be 10. Commonly it is 2
                      (which allows maximum density of a binary significand, and hidden-bit)
                      and a dynamic range of 1e-/+37 is roughly 2 up -/+123 for 8 bits of
                      exponent. But S/360 uses 16 (as you noted) and needs only 6 bits of
                      exponent for the same range. And it would be legal to use a larger
                      base, but the loss in significand precision grows much faster than the
                      gain in reduced exponent size, so people don't.

                      <snip rest>
                      - formerly david.thompson1 || achar(64) || worldnet.att.ne t

                      Comment

                      • Dann Corbit

                        #12
                        Re: long double

                        "David Thompson" <dave.thompson2 @verizon.netwro te in message
                        news:digl04533h 6k100034q1mj1c9 1ek3qjh5d@4ax.c om...
                        On Mon, 07 Apr 2008 14:40:55 -0400, Eric Sosman <Eric.Sosman@su n.com>
                        wrote:
                        >
                        >Bartc wrote:
                        <snip[long double] seems to be at least 32-bits.
                        >>
                        > This needs some explanation. There must be at least
                        >LDBL_DIG * lg(10) bit-equivalents in the fractional part
                        >of a long double, and since LDBL_DIG must be at least 10
                        >this implies a fraction of at least 33.2+ bit-equivalents.
                        >
                        Possibly minus 1 for hidden-bit, as already discussed.
                        >
                        >There must also be enough distinct exponent values to cover
                        >the range LDBL_MIN_10_EXP through LDBL_MAX_10_EXP , which
                        >must be at least the range -37 through +37; 75 or more
                        >distinct values implies lg(75) = 6.2+ bit-equivalents.
                        >
                        There is no need for the exponent's base to be 10. Commonly it is 2
                        (which allows maximum density of a binary significand, and hidden-bit)
                        and a dynamic range of 1e-/+37 is roughly 2 up -/+123 for 8 bits of
                        exponent. But S/360 uses 16 (as you noted) and needs only 6 bits of
                        exponent for the same range. And it would be legal to use a larger
                        base, but the loss in significand precision grows much faster than the
                        gain in reduced exponent size, so people don't.
                        I guess it is not true on a binary machine, but I once saw a proof that
                        maximum information density requires base e (and therefore, for integral
                        bases, 3 is a bit more compact than binary since it is closer to e than 2
                        is.) I guess that a ternary machine would be needed to express the data
                        most compactly using this representation.


                        ** Posted from http://www.teranews.com **

                        Comment

                        • CBFalconer

                          #13
                          Re: long double

                          Dann Corbit wrote:
                          >
                          .... snip ...
                          >
                          I guess it is not true on a binary machine, but I once saw a proof
                          that maximum information density requires base e (and therefore,
                          for integral bases, 3 is a bit more compact than binary since it
                          is closer to e than 2 is.) I guess that a ternary machine would
                          be needed to express the data most compactly using this
                          representation.
                          And then you have to consider the added physical complexity of
                          building a flip-flap-flop (in place of a flip-flop), and
                          implementing tri-level gates, etc.

                          --
                          [mail]: Chuck F (cbfalconer at maineline dot net)
                          [page]: <http://cbfalconer.home .att.net>
                          Try the download section.


                          ** Posted from http://www.teranews.com **

                          Comment

                          • user923005

                            #14
                            Re: long double

                            On Apr 22, 2:21 pm, CBFalconer <cbfalco...@yah oo.comwrote:
                            Dann Corbit wrote:
                            >
                            ... snip ...
                            >
                            I guess it is not true on a binary machine, but I once saw a proof
                            that maximum information density requires base e (and therefore,
                            for integral bases, 3 is a bit more compact than binary since it
                            is closer to e than 2 is.)  I guess that a ternary machine would
                            be needed to express the data most compactly using this
                            representation.
                            >
                            And then you have to consider the added physical complexity of
                            building a flip-flap-flop (in place of a flip-flop), and
                            implementing tri-level gates, etc.
                            With +voltage, ground, -voltage the idea is so obvious I would guess
                            someone has tried it.

                            Comment

                            • user923005

                              #15
                              Re: long double

                              On Apr 22, 3:31 pm, user923005 <dcor...@connx. comwrote:
                              On Apr 22, 2:21 pm, CBFalconer <cbfalco...@yah oo.comwrote:
                              >
                              Dann Corbit wrote:
                              >
                              ... snip ...
                              >
                              I guess it is not true on a binary machine, but I once saw a proof
                              that maximum information density requires base e (and therefore,
                              for integral bases, 3 is a bit more compact than binary since it
                              is closer to e than 2 is.)  I guess that a ternary machine would
                              be needed to express the data most compactly using this
                              representation.
                              >
                              And then you have to consider the added physical complexity of
                              building a flip-flap-flop (in place of a flip-flop), and
                              implementing tri-level gates, etc.
                              >
                              With +voltage, ground, -voltage the idea is so obvious I would guess
                              someone has tried it.

                              Comment

                              Working...