Greetings!
Raymond Toy <toy@rtp.ericsson.se> writes:
> >>>>> "Camm" == Camm Maguire <camm@enhanced.com> writes:
>
> Camm> (defun test-f (x i) (multiple-value-bind (q r s) (integer-decode-float
> Camm> x) (format t "~S~%" x) (and (eql x (float (* q (expt 2 r)))) (eql
> Camm> (float (float-rationalize x)) x )(if (> i 0) (test-f (float (* (+ q 1)
> Camm> (expt 2 r))) (- i 1)) t))))
>
> Camm> (test-f 1.0 10)
> Camm> 1.0
> Camm> 1.0000000000000002
> Camm> NIL
>
> Camm> (float (float-rationalize 1.0000000000000002))
>
> Camm> 1.0000000000000004
>
> Could be a problem with GCL's float reader/writer. Perhaps it's not
> reading/writing 1.000...2 correctly.
>
I don't think this is the case:
(integer-decode-float 1.0000000000000004)
4503599627370498
-52
1
>(integer-decode-float 1.0000000000000002)
4503599627370497
-52
1
>(eql 1.0000000000000004 1.0000000000000002)
NIL
> An alternative is to use CMUCL's rationalize function. This was
> stolen from Clisp (with permission) and converted to Lisp. Bruno
> Haible tends to implement very good numerical stuff. I haven't tested
> whether it works in for possible numbers.
>
OK, will consider after Stavros gets a chance to look into things next
week. Thanks again to all!
Take care,
> Ray
>
>
>
>
> _______________________________________________
> Gcl-devel mailing list
> Gcl-devel@gnu.org
> http://mail.gnu.org/mailman/listinfo/gcl-devel
>
>
>
--
Camm Maguire camm@enhanced.com
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah