[gambit-list] Results of subtraction don't match "The Scheme Programming Language"

Pierpaolo Bernardi olopierpa at gmail.com
Tue Dec 30 15:43:44 EST 2014


Both 1.0 and 1. are acceptable ways in scheme for writing the same number.

To convince yourself that it is the same number you can try: (eqv? 1.0 1.)


On Tue, Dec 30, 2014 at 9:07 PM, Steve Graham <jsgrahamus at yahoo.com> wrote:
> On page16 of the above book, it show (- 1.5 1/2) returning 1.0.
>
> When I do such in Gambit, I get:
> Gambit v4.7.3
>
>> (+ 1/2 1/2)
> 1
>> (- 1.5 1/2)
> 1.
>
> Here are some other results:
> Chicken Scheme
> #;1> (- 1.5 1/2)
>
> Warning: cannot represent exact fraction - coerced to flonum: "1/2"
> 1.
> #;2>
>
> Racket
> C:\Users\Steve>racket
> Welcome to Racket v6.0.1.
>> (- 1.5 1/2)
> 1.0
>>
>
> Larceny
> Larceny v0.97 "Funny in the Head" (Aug 19 2009 14:35:39,
> precise:Win32:unified)
>
>> (- 1.5 1/2)
> 1.0
>
>>
>
> MIT Scheme
> (- 1.5 1/2)
> ;Value: 1.
>
> Petite Chez Scheme
>> (- 1.5 1/2)
> 1.0
>>
>
> SCM 5e7
>> (- 1.5 1/2)
> 1.0
>>
> Why is there such a variety?
>
> Steve
>
>
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>



More information about the Gambit-list mailing list