semifloscular

openmcl version of decode-float32 uses decode-uint32 for correct negative float values.

darcs-hash:20051205190701-2648a-06b565475c79901f26175fd84374bdb0314381b6.gz
This commit is contained in:
nik gaffney 2005-12-06 03:07:01 +08:00
parent d8ffcab7b3
commit 73f33aac45
3 changed files with 13 additions and 2 deletions

View file

@ -42,6 +42,9 @@ things to do in :osc-ex[tensions|tras]
changes
2005-12-05
- version 0.3
- fixed openmcl float bug (decode-uint32)
2005-11-29
- version 0.2
- openmcl float en/decoding

View file

@ -7,5 +7,5 @@
:author "nik gaffney <nik@fo.am>"
:licence "LLGPL"
:description "The Open Sound Control protocol, aka OSC"
:version "0.2"
:version "0.3"
:components ((:file "osc")))

View file

@ -258,7 +258,7 @@
"ieee754 float from a vector of 4 bytes in network byte order"
#+sbcl (sb-kernel:make-single-float (decode-int32 s))
#+cmucl (kernel:make-single-float (decode-int32 s))
#+openmcl (CCL::HOST-SINGLE-FLOAT-FROM-UNSIGNED-BYTE-32 (decode-int32 s))
#+openmcl (CCL::HOST-SINGLE-FLOAT-FROM-UNSIGNED-BYTE-32 (decode-uint32 s))
#-(or sbcl cmucl openmcl) (error "cant decode floats using this implementation"))
(defun decode-int32 (s)
@ -271,6 +271,14 @@
(- 0 (- #x100000000 i))
i)))
(defun decode-uint32 (s)
"4 byte -> 32 bit unsigned int"
(let ((i (+ (ash (elt s 0) 24)
(ash (elt s 1) 16)
(ash (elt s 2) 8)
(elt s 3))))
i))
(defun encode-int32 (i)
"convert an integer into a sequence of 4 bytes in network byte order."
(declare (type integer i))