[Chicken-users] From inexact to exact using the - procedure?

2012-03-23 Thread Jeronimo Pellegrini
Hello,

I'm not sure if this is a bug or a feature:

#;1 (use numbers)
#;2 (define y (* 0.1 1+1i))
#;3 (define a (+ 1 y))
#;4 (define b (+ 2 y))
#;5 (- a b)
1.0
#;6 (exact? (- a b))
#f

That's what I expected... The imaginary part vanished,
but it's like doing (- 0.1 0.1) -- it's not exact!

Now...

#;7 (- 1+0.1i 2+0.1i)
-1
#;8 (exact?  (- 1+0.1i 2+0.1i))
#t

Well, that's supposed to be exactly the same thing,
so why is it exact? Is this an optimization?

Thanks,
J.


___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] From inexact to exact using the - procedure?

2012-03-23 Thread Peter Bex
On Fri, Mar 23, 2012 at 04:37:06PM -0300, Jeronimo Pellegrini wrote:
 Hello,
 
 I'm not sure if this is a bug or a feature:
 
 #;1 (use numbers)
 #;2 (define y (* 0.1 1+1i))
 #;3 (define a (+ 1 y))
 #;4 (define b (+ 2 y))
 #;5 (- a b)
 1.0
 #;6 (exact? (- a b))
 #f

With numbers trunk:

#;1 (use numbers)
#;2 (define y (* 0.1 1+1i)) 
#;3  (define a (+ 1 y))
#;4 (define b (+ 2 y))
#;5 (- a b)
-1.0
#;6 (exact? (- a b)) 
#f

 That's what I expected... The imaginary part vanished,
 but it's like doing (- 0.1 0.1) -- it's not exact!
 
 Now...
 
 #;7 (- 1+0.1i 2+0.1i)
 -1
 #;8 (exact?  (- 1+0.1i 2+0.1i))
 #t

trunk:

#;7  (- 1+0.1i 2+0.1i)
-1.0
#;8 (exact?  (- 1+0.1i 2+0.1i))
#f

 Well, that's supposed to be exactly the same thing,
 so why is it exact? Is this an optimization?

It's a bug.  There are many, many bugs in the current release
of the numbers egg.  I'm working hard on a new release, which
should be done soonish.

In the meanwhile, could you please use numbers trunk?  It would
be very helpful to actually have users testing it before I make
yet another broken release :)

Quoting from another mail I posted to chicken-hackers yesterday:
I know these fixes have been a long time coming, and I'm sorry that it's
taking so long, however I hope to tag a new numbers release soonish.
There have been many many bugs fixed in this new version, and it will
include (*limited*) support for extended number syntax in _compiled_ code.

Along with this, it will include a types database to support
scrutiny/specialization so that at least for flonum operations things
will be as fast as core Chicken, and it will help to find bugs in code
much easier when compiling.  Thanks to Felix for pushing me to support
this and developing the initial types database!

I will make a release once I've convinced myself that the numbers
database is complete and correct.  This will probably involve extending
the test suite some more (as I've been doing the past two weeks).

You can get the trunk version of numbers like this:

$ svn co --username anonymous --password '' \
   https://code.call-cc.org/svn/chicken-eggs/release/4/numbers/trunk numbers
$ cd numbers
$ chicken-install

I'm truly sorry for the inconvenience!

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music.
-- Donald Knuth

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] From inexact to exact using the - procedure?

2012-03-23 Thread Christian Kellermann
Hi Jeronimo,

* Jeronimo Pellegrini j...@aleph0.info [120323 21:16]:
 I'm not sure if this is a bug or a feature:
 
 #;1 (use numbers)
 #;2 (define y (* 0.1 1+1i))

I am not a numbers expert but I think you have tainted your exactness
by using an inexact flonum.

Try:

#;10 (define y (* 1+1i #e0.1))
#;11 (define a (+ 1 y)) 
#;12 (define b (+ 2 y))
#;13 (exact? (- a b))
#t

Alternatively divide by 10...

Does this make sense to you?

HTH,

Christian

-- 
9 out of 10 voices in my head say, that I am crazy,
one is humming.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] From inexact to exact using the - procedure?

2012-03-23 Thread John Cowan
Jeronimo Pellegrini scripsit:

 #;5 (- a b)
 1.0

The imaginary part vanishes because R5RS treats 1.0+0.0i as a real number.
However, R6RS does not and R7RS currently does not either, though that
may change as a result of a current debate.  The rationale is that you
don't know if the complex number is actually on the real line or just
too close to it to discriminate.

-- 
Overhead, without any fuss, the stars were going out.
--Arthur C. Clarke, The Nine Billion Names of God
John Cowan co...@ccil.org

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users