[Openmcl-devel] Printing/Reading floats

Christophe Rhodes csr21 at cam.ac.uk
Mon Mar 17 10:01:58 PST 2003


Raymond Wiker <Raymond.Wiker at fast.no> writes:

> Christophe Rhodes writes:
>  > IANAFPExpert, but would
>  > 
>  > (defun hypothetical-integer-encode-float (sig exp sign)
>  >   (float (* sign (/ sig (expt 2 exp)))))
>  > 
>  > be close?  Obviously there are issues wrt single/doubleness, but...
                                           ^^^^^^^^^^^^^^^^^^^^^

> (defun hypothetical-integer-encode-float (sig exp sign)
>   (* sign (scale-float (float sig) exp)))
>
>         (Actually, I just tried this, in SBCL, with pi - didn't look
> to good :-)

Yeah, it wouldn't -- FLOAT gives you a single float.

you could instead use COERCE <stuff> *READ-DEFAULT-FLOAT-FORMAT*, or
somesuch... but I think this is beyond the hypothetical use of
HYPOTHETICAL-INTEGER-ENCODE-FLOAT :-)

Cheers,

Christophe
-- 
http://www-jcsu.jesus.cam.ac.uk/~csr21/       +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%")    (pprint #36rJesusCollegeCambridge)

_______________________________________________
Openmcl-devel mailing list
Openmcl-devel at clozure.com
http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel



More information about the Openmcl-devel mailing list