From: Ivan Boldyrev
Subject: LDB and signed-byte
Date: 
Message-ID: <d21ll1x7p9.ln2@ibhome.cgitftp.uiggm.nsc.ru>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

It seems, LDB always return UNSIGNED-BYTE (at least in CMU CL).
HyperSpec doesn't explain if result is signed or not, result of
LDB is INTEGER, not just UNSIGNED-BYTE.

(loop :from i :from 1 :to 512 :collect (ldb (byte 8 0) i))

will return list (1 2 ... 254 255 0 1 2 .. 245 255 0).  I need some
function that will return signed value:

(1 2 ... 127 -128 ... -2 -1 0 1 2 .. -2 -1 0).

Of course I can use (- (ldb (byte 8 0) (+ i 128)) 128), but it is
inefficient.

Second argument of ROUND is not exactly what I want:

> (defun m (x)
           (multiple-value-bind (a b) (round x 256)
             (declare (ignore a))
             b))
>  (m 127)
=> 127

>  (m 128)
=> 128
>  (m 129)
=> -127

But I want (m 128) => -128.

Can you suggest any another function?

P.S.  Actually, I just want to fill long array of (SIGNED-BYTE 8) with
test data -- "cycling" signed bytes.

- -- 
Ivan Boldyrev

                        Today is the first day of the rest of your life.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.3.5 (GNU/Linux)

iQEVAwUBQIfVLA4ALcwzZFpVAQI9+Qf+N5j5W6VaRzSOy6o5qnEYW9ZmazPuHkOc
109R+awFg0R8JW9b0qR49Xkkar3mo616JbCxoq6rz7FkNeOrd4jjzyGv7l2dHbG/
L+ovpDJR2ft1GCl1Lr54gkFgNvt5txoRRaSP2HUwDsnwuaDIwokMSKfboxHQfMf8
tnluXAIBm5xHlEOrExp8Xhk/SSTyoRIW81Zx6WoKrMEa0E4hNI8kacvuBSkzwjnn
q8/paGpNdVKeoukDhJFkBdCa55CNy1oZOw4AsPvbiokX3YI8M68t7wjcU0Vwa7sI
s3ahT9AnwwlJU3xnmVvrMw7twO2aSH0cLrGHbCHRbstqzVyTjzQTCg==
=iNvx
-----END PGP SIGNATURE-----
From: Paul F. Dietz
Subject: Re: LDB and signed-byte
Date: 
Message-ID: <4088804C.5070800@dls.net>
Ivan Boldyrev wrote:

> It seems, LDB always return UNSIGNED-BYTE (at least in CMU CL).
> HyperSpec doesn't explain if result is signed or not, result of
> LDB is INTEGER, not just UNSIGNED-BYTE.

It is clearly always nonnegative, since the result has a finite
number of 1 bits and an infinite number of 0 bits (negative numbers
are the opposite, with a finite number of 0 bits and an infinite
number of 1 bits.)

	Paul