Results of subtraction don't match "The Scheme Programming Language"
30 Déc
2014
30 Déc
'14
20:07
(+ 1/2 1/2) 1 (- 1.5 1/2)
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. Here are some other results:Chicken Scheme#;1> (- 1.5 1/2) Warning: cannot represent exact fraction - coerced to flonum: "1/2" 1. #;2> RacketC:\Users\Steve>racket Welcome to Racket v6.0.1.
(- 1.5 1/2) 1.0
LarcenyLarceny 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
Afficher les réponses par date
30 Déc
30 Déc
20:43
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@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@iro.umontreal.ca > https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list >
4185
Âge (en jours)
4185
Dernière activité (en jours)
1 commentaires
2 participants
participants (2)
-
Pierpaolo Bernardi -
Steve Graham