From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!feed.news.nacamar.de!uninett.no!ntnu.no!uio.no!nntp.uio.no!ifi.uio.no!not-for-mail From: Erik Naggum Newsgroups: comp.lang.lisp Subject: Re: Converting bytes to an integer Date: 12 Sep 2002 17:32:43 +0000 Organization: Naggum Software, Oslo, Norway Lines: 18 Message-ID: <3240840763579547@naggum.no> References: <85admn7hxr.fsf@junk.nocrew.org> <8565xb7hm1.fsf@junk.nocrew.org> <2hhegvjzc9.fsf@vserver.cs.uit.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: maud.ifi.uio.no 1031851963 12925 129.240.64.16 (12 Sep 2002 17:32:43 GMT) X-Complaints-To: abuse@ifi.uio.no NNTP-Posting-Date: 12 Sep 2002 17:32:43 GMT Mail-Copies-To: never User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.lisp:40472 * 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.