moschatels (ints)
This commit is contained in:
parent
5c7ed79a7f
commit
f647738ccc
2 changed files with 24 additions and 17 deletions
|
@ -48,11 +48,18 @@
|
|||
(is (equalp
|
||||
(osc::encode-int32 16843009) #(1 1 1 1)))
|
||||
(is (equalp
|
||||
(osc::decode-int32 #(1 1 11 111)) 16845679))
|
||||
(osc::decode-int32 #(127 255 255 255))
|
||||
(osc::decode-uint32 #(127 255 255 255))))
|
||||
(is (equalp
|
||||
(osc::encode-int32 -16843010) #(254 254 254 254)))
|
||||
(is (equalp
|
||||
(osc::decode-int32 #(255 255 255 255)) -1)))
|
||||
(osc::decode-int32 #(127 255 255 255)) #x7FFFFFFF))
|
||||
(is (equalp
|
||||
(osc::encode-int32 #xFFFFFFFF) #(255 255 255 255)))
|
||||
(is (equalp
|
||||
(osc::decode-int32 #(255 255 255 255)) -1))
|
||||
(is (equalp
|
||||
(osc::decode-uint32 #(255 255 255 255)) #xFFFFFFFF)))
|
||||
|
||||
(test osc-string
|
||||
"OSC string encoding tests."
|
||||
|
|
8
osc.lisp
8
osc.lisp
|
@ -325,15 +325,15 @@
|
|||
(defun decode-int32 (s)
|
||||
"4 byte -> 32 bit int -> two's complement (in network byte order)"
|
||||
(let ((i (decode-uint32 s)))
|
||||
(if (>= i #.(1- (expt 2 31)))
|
||||
(- (- #.(expt 2 32) i))
|
||||
(if (>= i (expt 2 31))
|
||||
(- (- (expt 2 32) i))
|
||||
i)))
|
||||
|
||||
(defun decode-int64 (s)
|
||||
"8 byte -> 64 bit int -> two's complement (in network byte order)"
|
||||
(let ((i (decode-uint64 s)))
|
||||
(if (>= i #.(1- (expt 2 63)))
|
||||
(- (- #.(expt 2 64) i))
|
||||
(if (>= i (expt 2 63))
|
||||
(- (- (expt 2 64) i))
|
||||
i)))
|
||||
|
||||
;; floats are encoded using ieee-floats library for brevity and compatibility
|
||||
|
|
Loading…
Reference in a new issue