10 Jan
2017
10 Jan
'17
11:37 p.m.
Since we are on the subject…
I am looking at ieeefp-tests.
The code for CMUCL (the relevant one, I assume) looks like this:
(defun make-single-float (x) (declare (type (or (unsigned-byte 32) (signed-byte 32)) x)) (typecase x ((signed-byte 32) (kernel:make-single-float x)) (t (kernel:make-single-float (dpb x (byte 32 0) -1)))))
(defun make-single-float (x) (declare (type (or (unsigned-byte 32) (signed-byte 32)) x)) (cffi:with-foreign-object (p :uint32) (setf (cffi:mem-ref p :uint32) x) (cffi:mem-ref p :float))) Definitely portable across Lisps and probably across CPUs. If you don't care about the former, use LW's own FFI. -- Stelian Ionescu a.k.a. fe[nl]ix Quidquid latine dictum sit, altum videtur.