Re: Decimal Floating Point (was Re: why still use C?)

From: Gene Wirchenko (genew_at_mail.ocis.net)
Date: 12/09/03


Date: 09 Dec 2003 00:15:01 GMT


"Eric Backus" <eric_backus@alum.mit.edu> wrote:

>"Mike Cowlishaw" <mfcowli@attglobal.net> wrote in message
>news:clcm-20031202-0003@plethora.net...
>> Dan Pop wrote:
>> > And what is the exact result of dividing 1 penny by 3, when using
>> > decimal floating point arithmetic? Or is division a prohibited
>> > operation for this class of applications?
>>
>> This is exactly why floating-point is the right solution. Whenever
>> the result is Inexact, you get the best possible approximation to
>> the 'ideal' result -- that is, full precision. With a fixed scaling
>> factor you cannot make full use of the precision unless you
>> know how many digits there will be to the left of the radix
>> point.
>
>You also get the best possible approximation to the 'ideal' result if you
>use binary floating-point. I'm sure you know this, but it's worth
>emphasizing anyway: decimal floating point does *not* get rid of the inexact
>nature of floating-point operations for the majority of calculations.

     I have not seen that anyone is saying that it does. It does give
less astonishing results though (as in Law of Least Astonishment).

>It seems to me that the *only* thing decimal floating point gets you is
>conformance to the conventions used by the financial community for how to
>deal with that inexactness. You can do that today with a library, so the
>only thing that hardware support gets you is faster computations for those
>calculations where this is a requirement.

     The same would be true of binary floating point. Some have
raised the point that decimal floating point would raise the bar for
some embedded applications. Let us remove all floating point from the
language and handle it with libraries. If that does not seem too
appetising to you, consider how the people who want decimal float
feel.

     I have long felt that the lack of decimal floating point is a
severe lack in many languages.

>Note that this library could be implemented in assembly on those platforms
>that have hardware support, so you don't really even need native C support
>for decimal floating point in order to get the faster computations. Of
     ^^^^^^^
      Replace with "any".

>course, using such a library is inconvenient compared to having native C
>support, but that inconvenience is payed only by those who need this
>capability. Is that group of people large enough that inconveniencing them

     That is quite right. Many of the programs that I write do not
use floating point at all. Let us get rid of the baggage of floating
point. I mean, I could consider others, but a little inconvenience
will, ah, strengthen them.

>justifies changing the language?

     You will never know for sure until it is available. If I need
decimal floating point in an app and C does not have it, C is out of
the running. I will not make elaborate complaints; I will simply not
consider an language that is inadequate to my requirements.

     I understand that some people think that C should be inadequate
in this regard. It might be different if their ox were being gored.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
     I have preferences.
     You have biases.
     He/She has prejudices.

-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net


Relevant Pages

  • Re: Union test for endianess
    ... floating point math, but no hardware support for large integer types. ...
    (comp.lang.c)
  • Re: Packed decimal arithmetic in C
    ... >>I once used double precision floating point in exactly that manner. ... >>It made sense since I had compiler and hardware support for D floating ... compound interest calculations require a larger ... > A scaled integer meets the requirement of exactness. ...
    (comp.os.vms)
  • Re: Fixed point Vs Floating point
    ... Alas, not the 68020, nor the 68030; ... that sported onboard floating point (the hardware support ...
    (sci.electronics.design)
  • Re: Fixed point Vs Floating point
    ... Alas, not the 68020, nor the 68030; ... that sported onboard floating point (the hardware support ...
    (sci.electronics.design)
  • Re: VB6 Type Conversion Errors
    ... Floating point values can't represent numbers not based on powers of 2 (this ... As it turns out, that approximation is ... When you perform the calculation first and assign it to a Double, ...
    (comp.lang.basic.visual.misc)