Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use Lispworks FLI to implement single-float-bits.

Doing the same for double-float-bits doesn't seem to work.
  • Loading branch information...
commit da903f7368bc6cb460e92fb44dc95a744e24df1f 1 parent add374a
@brown authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 lispworks-float.lisp
View
9 lispworks-float.lisp
@@ -37,14 +37,17 @@
(defun single-float-bits (x)
(declare (type single-float x))
- ;; TODO(brown): Implement using Lispworks FLI functions.
- (portable-float:single-float-bits x))
+ (fli:with-dynamic-foreign-objects ((bits :int32))
+ (fli:with-coerced-pointer (pointer :type :lisp-single-float) bits
+ (setf (fli:dereference pointer) x))
+ (fli:dereference bits)))
(declaim (ftype (function (double-float) (values (signed-byte 64) &optional)) double-float-bits))
(defun double-float-bits (x)
(declare (type double-float x))
- ;; TODO(brown): Implement using Lispworks FLI functions.
+ ;; TODO(brown): Implement using Lispworks FLI functions. Right now, an implementation like the
+ ;; one above for single floats sometimes loses precision.
(portable-float:double-float-bits x))
(declaim (ftype (function ((signed-byte 32)) (values single-float &optional)) make-single-float))
Please sign in to comment.
Something went wrong with that request. Please try again.