in reply to Re: Strange rounding Error in Perl
in thread Strange rounding Error in Perl

I don't think you were right about COBOL, so better remove it from your assertion ;-) COBOL supports fixed decimal, you can define picture like 99.99 etc.

Replies are listed 'Best First'.
Re^3: Strange rounding Error in Perl
by davido (Cardinal) on Nov 23, 2004 at 04:46 UTC

    No, floating point math operations in COBOL are suceptible to the binary to decimal conversion problem too. Defining a picture, or whatever you want to call it is essentially forcing rounding to hide the problem. COBOL allows for fixed decimal numbers, and they're handled differently internally. They're not floating point. For floating point math, the decimal to binary conversion error is still there. You're just not seeing it easily because the language is masking it by rounding, and by not showing all of the available digits, and that is exactly what I meant by saying that languages that don't show this behavior are telling a lie.

    Calculators hide the error too, again, by not showing all digits, and by rounding.


    Dave