Subject: Re: Converting bytes to an integer
From: Erik Naggum <>
Date: 12 Sep 2002 17:32:43 +0000
Newsgroups: comp.lang.lisp
Message-ID: <>

* Frode Vatvedt Fjeld <>
| This looks good to me, but I'd prefer something like this:
|  (defun bytes-to-int (bytes start end)
|    "Convert the bits of a little-endian 8-bit byte array to an integer."
|    (reduce (lambda (x y) (+ (* 256 x) y)) bytes :start start :end end))

  I would much prefer

(reduce (lambda (x y) (logior (ash x 8) y)) bytes :start start :end end)

  This is not a job for multiplication and addition.

Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.