Commit 225ceb4b authored by Frode Vatvedt Fjeld's avatar Frode Vatvedt Fjeld

Have sign-extend-complex deal correctly with bytes of size 0.

parent e2bf2258
......@@ -9,7 +9,7 @@
;;;; Created at: Thu May 4 15:16:45 2000
;;;; Distribution: See the accompanying file COPYING.
;;;;
;;;; $Id: codec.lisp,v 1.6 2004/09/02 09:01:19 ffjeld Exp $
;;;; $Id: codec.lisp,v 1.7 2005/08/13 20:24:04 ffjeld Exp $
;;;;
;;;;------------------------------------------------------------------
......@@ -672,10 +672,13 @@ byte represents the sign), return the natural representation of
that byte (i.e. #c(255 1) => -1)."
(let ((old-byte (realpart cdatum))
(numo (imagpart cdatum)))
(if (zerop (ldb (byte 1 (1- (* 8 numo))) old-byte))
cdatum
(complex (- old-byte (dpb 1 (byte 1 (* 8 numo)) 0))
numo))))
(cond
((= 0 numo)
0)
((zerop (ldb (byte 1 (1- (* 8 numo))) old-byte))
cdatum)
(t (complex (- old-byte (dpb 1 (byte 1 (* 8 numo)) 0))
numo)))))
(defun sign-extend (old-byte numo)
"Given a two's complement signed byte (where the most significant
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment