chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Rational numbers not working as expected


From: Nick Vaughn
Subject: [Chicken-users] Rational numbers not working as expected
Date: Wed, 6 Mar 2013 13:58:48 -1000

I'm having fun learning scheme using chicken.   Looking at the manual, I see that there is deviation from the R5RS standard in that numerator and denominator procedures cannot be applied to inexact numbers.  But I can't figure out how to make an exact rational. Tried (/ 6 4) and 6/4, but neither works.

Running on arch-linux amd64, the arch package and compiling from git source both have the same effect.

#csi -n

CHICKEN
(c)2008-2011 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.7.0 
linux-unix-gnu-x86 [ manyargs dload ptables ]
compiled 2011-10-17 on roseapple (Linux)

#;1> (rational? 6/10)
Warning: cannot represent exact fraction - coerced to flonum: "6/10"
#t
#;2> (rational? (/ 6 10))
#t
#;3> (exact? 6/10)

Warning: cannot represent exact fraction - coerced to flonum: "6/10"
#f
#;4> (exact? (/ 6 10))
#f


#;5> (numerator (/ 6 10))

Error: (numerator) bad argument type - not a rational number: 0.6

Call history:

<syntax>  (numerator (/ 6 10))
<syntax>  (/ 6 10)
<eval>  (numerator (/ 6 10))
<eval>  (/ 6 10) <--
#;6> (numerator 6/10)

Warning: cannot represent exact fraction - coerced to flonum: "6/10"

Error: (numerator) bad argument type - not a rational number: 0.6

Call history:

<syntax>  (numerator 0.6)
<eval>  (numerator 0.6) <--


Am I missing something?
-Nick

reply via email to

[Prev in Thread] Current Thread [Next in Thread]