chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Why doesnot "(+ 1/2 1/3)" equal to 5/6 ?


From: .alyn.post.
Subject: Re: [Chicken-users] Why doesnot "(+ 1/2 1/3)" equal to 5/6 ?
Date: Wed, 7 Nov 2012 18:59:33 -0700

On Thu, Nov 08, 2012 at 01:30:44AM -0000, z_axis wrote:
> Welcome to Racket v5.3.
> -> (+ 1/2 1/3)
> 5/6
> 

If you look carefully at your below message, you have unbalanced
parenthesis, which I was joking about when I spoke of a syntax
error.  The error did not affect the clarity of what you were
asking.  Consider my comment a too-subtle "like a joke only not
as funny." missive.

> BTW, what do the following message mean ?
> (use numbers)
> ; loading /usr/local/lib/chicken/6/numbers.import.so ...
> 
> Note: re-importing already imported identifier: +
> 
> Note: re-importing already imported identifier: -
> 
> Note: re-importing already imported identifier: *
> 
> Note: re-importing already imported identifier: /
> ......
> 

Chicken Scheme has a small "base system" that contains a minimal
feature set.  Certain eggs (specifically numbers and utf8) will
amend this basic feature set with more powerful versions of
existing routine.

These messages are describing that phenomenon: the routine '+'
exists in the core Chicken Scheme system, but does not, as you
have observed, implement the full numeric tower.  The numbers
egg replaces the core '+' routine with it's own, as it does
everything the core '+' does and substantially more.

-Alan

> Best Regards!
> 
> 
> 在 Thu, 08 Nov 2012 00:17:23 -0000,.alyn.post.
> <address@hidden> 写道:
> 
> >On Wed, Nov 07, 2012 at 11:57:33PM -0000, z_axis wrote:
> >>
> >>>(+ (+ 1/2 1/3)
> >>
> >>Warning: cannot represent exact fraction - coerced to flonum: "1/2"
> >>Warning: cannot represent exact fraction - coerced to flonum: "1/3"
> >>0.8333333333333331/2 1/3)
> >>
> >>
> >>In racket, it is 5/6. And as i know it is 5/6 for any lisp
> >>implementation.
> >>
> >>
> >>Sincerely!
> >>
> >
> >I suspect in Racket your above code is a syntax error.  ;-)
> >
> >More seriously, try this:
> >
> >  (use numbers)
> >  (+ (+ 1/2 1/3))
> >
> >That gives you the answer you expect.
> >
> >-Alan
> 

-- 
.i ma'a lo bradi cu penmi gi'e du



reply via email to

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