Unfortunately I have inexact number in a complicated structure. :(
The example below was only a little demonstration.

So I just tried the numbers egg, but as you told it does not help.
And I cannot change to an other scheme implementation because of a special
API egg.
I tried two other (chez, mzscheme), but nor of them have the same problem.

Do you have any method to read/write complicated structures in such cases
easily?
Or I have to implement an own write function which converts every inexact
number...

Thx,
`bg`


On 26/08/07, Kon Lovett <[EMAIL PROTECTED]> wrote:
>
>
> On Aug 25, 2007, at 1:44 PM, Gábor Balázs wrote:
>
> Hello,
>
> I tried the following with chicken 2.6:
>
>     (define v1 (/ 1 3))
>     (call-with-output-file "try.dat"
>                            (lambda (port)
>                              (write v1 port)))
>
>     (define v2 (call-with-input-file "try.dat"
>                                      (lambda (port)
>                                        (read port))))
>     (print "v1 = " v1)
>     (print "v2 = " v2)
>     (print (equal? v1 v2))
>     (print (= v1 v2))
>     (print (- v1 v2))
>
> And the result was:
>
>     v1 = 0.333333333333333
>     v2 = 0.333333333333333
>     #f
>     #f
>     3.33066907387547e-16
>
> Is it a known bug?
>
>
> Yes. See http://galinha.ucpel.tche.br/Deviations%20from%20the%20standard [
> 6.6.4]
>
> This is real "gotcha" in core Chicken. See the " numbers" egg.
>
> $ csi
>
> this is CHICKEN
> Version 2.637 - macosx-unix-gnu-ppc - [ manyargs dload ptables extraslot
> applyhook autotools ]
> (c)2000-2007 Felix L. Winkelmann
> ; loading /Users/klovett/.csirc ...
> #;1> (use numbers)
> ; loading /usr/local/lib/chicken/1x/numbers.scm ...
> ; loading /usr/local/lib/chicken/1x/numbers-base.so ...
> #;2> (define v1 (/ 1 3))
>     (call-with-output-file "try.dat"
>                            (lambda (port)
>                              (write v1 port)))
>
>     (define v2 (call-with-input-file "try.dat"
>                                      (lambda (port)
>                                        (read port))))
>     (print "v1 = " v1)
>     (print "v2 = " v2)
>     (print (equal? v1 v2))
>     (print (= v1 v2))
>     (print (- v1 v2)) #;3> #;4> #;5> v1 = 1/3
> "v1 = "
> #;6> v2 = 1/3
> "v2 = "
> #;7> #t
> #t
> #;8> #t
> #t
> #;9>
>
> However , this only works because the 'v' values are exact! '(define
> v1 (exact->inexact (/ 1 3)))' still has the read/write invariance problem.
>
> I tried to report this, but I did not find the easy way.
>
>
> See http://trac.callcc.org/
>
>
> `bg`
> _______________________________________________
> Chicken-users mailing list
> [email protected]
> http://lists.nongnu.org/mailman/listinfo/chicken-users
>
>
>
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to