Re: [dssslist] Arithmetic error

Subject: Re: [dssslist] Arithmetic error
From: "Paul Tyson" <paul@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 7 Apr 2005 10:36:50 -0500 (CDT)
I get the same results with MIT Scheme.  It appears to be allowable by the
Scheme specification.  I did not check the DSSSL spec.

The problem is that decimal numbers are inexact.  If you evaluate
   (- 7.2 7)

you get something like .200000000018

but
    (- 7.1 7)
gives something like .09999999999964.

You might get the results you want by writing the tests with exact values
like so:

    (< (- (/ 71 10) 7) (/ 1 10))
and
    (< (- (/ 72 10) 7) (/ 2 10))

--Paul

>
> 	Hello everybody!
>
> 	I obtained today an erroneous result in an arithmetic operation using
> DSSSL. I began the typical prozess to minimize the field where the error
> appears, and the result was a surprise for me...
>
> 	The result of this piece of code:
> ;**********************************************************************************************
>
>     (make sequence
>        (if (< (- 7.1 7) 0.1)
>           (literal (string-append (number->string (- 7.1 7)) " is less as
> 0.1"))
>           (literal (string-append (number->string (- 7.1 7)) " is NOT less
> as 0.1"))
>        )
>        (literal " BUT: ")
>        (if (< (- 7.2 7) 0.2)
>           (literal (string-append (number->string (- 7.2 7)) " is less as
> 0.2"))
>           (literal (string-append (number->string (- 7.2 7)) " is NOT less
> as 0.2"))
>        )
>     )
> ;**********************************************************************************************
>
>
> 	is this:
>
> 0.1 is less as 0.1 BUT: 0.2 is NOT less as 0.2
>
>
> 	Do you know something about this? Could it be because of my version of
> Jade?
>
>
> 	I thank you all in advance for your help. Have a nice day!
>
> 	Alberto Martmnez Pascual

Current Thread