chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Rational numbers not working as expected


From: Mario Domenech Goulart
Subject: Re: [Chicken-users] Rational numbers not working as expected
Date: Wed, 06 Mar 2013 18:51:10 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Hi Nick,

On Wed, 6 Mar 2013 13:58:48 -1000 Nick Vaughn <address@hidden> wrote:

> 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?

You probably need the numbers egg: http://wiki.call-cc.org/egg/numbers

  $ chicken-install numbers
  $ csi
  #;1> (use numbers)
  ...


Best wishes.
Mario
-- 
http://parenteses.org/mario



reply via email to

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