[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gcl-devel] Re: [Maxima] float to bfloat
From: |
Camm Maguire |
Subject: |
Re: [Gcl-devel] Re: [Maxima] float to bfloat |
Date: |
23 Jan 2004 11:01:44 -0500 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Greetings!
Raymond Toy <address@hidden> writes:
> >>>>> "Camm" == Camm Maguire <address@hidden> 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
> address@hidden
> http://mail.gnu.org/mailman/listinfo/gcl-devel
>
>
>
--
Camm Maguire address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah
- [Gcl-devel] Re: [Maxima] float to bfloat, Camm Maguire, 2004/01/23
- [Gcl-devel] Re: [Maxima] float to bfloat, Raymond Toy, 2004/01/23
- Re: [Gcl-devel] Re: [Maxima] float to bfloat,
Camm Maguire <=
- Re: [Gcl-devel] Re: [Maxima] float to bfloat, Raymond Toy, 2004/01/23
- Re: [Gcl-devel] Re: [Maxima] float to bfloat, Camm Maguire, 2004/01/26
- Re: [Gcl-devel] Re: [Maxima] float to bfloat, Richard Fateman, 2004/01/26
- Re: [Gcl-devel] Re: [Maxima] float to bfloat, Camm Maguire, 2004/01/26
- RE: [Gcl-devel] Re: [Maxima] float to bfloat, Stavros Macrakis, 2004/01/26
- Re: [Gcl-devel] Re: [Maxima] float to bfloat, Camm Maguire, 2004/01/30
- Re: [Gcl-devel] Re: [Maxima] float to bfloat, Raymond Toy, 2004/01/30
- Re: [Gcl-devel] Re: [Maxima] float to bfloat, Richard Fateman, 2004/01/30
- Re: [Gcl-devel] Re: [Maxima] float to bfloat, Raymond Toy, 2004/01/30
- Re: [Gcl-devel] Re: [Maxima] float to bfloat, Camm Maguire, 2004/01/30