From: Christopher Browne
Subject: Re: What language to learn
Date: 
Message-ID: <m3u1scyujo.fsf@chvatal.cbbrowne.com>
"David Rasmussen" <··············@yahoo.com> wrote:
> One question: Can I get a 64-bit integer in Common Lisp? Can I use binary
> logical operators on them?

Common Lisp offers the BIGNUM integer type that allows integers as big
as you like.

> (defvar a 5000000000)
A
> (defvar b 6233000444571)
B
> (* a b)
31165002222855000000000
> (list (logxor a b) (logand a b) (logior a b))
(6228000567451 4999938560 6233000506011)
> 

(Note that I ran the above on CLISP and CMU/CL, getting identical
results; it is portable to various CL implementations...)

Processing BIGNUMs involves some degree of "interpreting" the numbers,
with the upshot that it's not going to be as fast as working with bald
64 bit values in a system that is aware of 64 bit values as a
specialized type.

On a 64 bit architecture, those values would involve single CPU
instructions and single registers, and be "blindingly" fast; on 32 bit
architectures, "double precision 64 bit integers" could certainly be
specialized type with fine-tuned performance.

But this begs the question: What use do you plan to make of the ops?
If you're planning to do DSP-like work, involving _heavy_ use of 64
bit values, you'd probably want to create a specialized type with
specially written operators, perhaps written in assembly language for
maximum speed.

But absent of knowledge of that, if you only know you need
_occasional_ 64 bit operations, BIGNUMs are certainly going to do the
trick, and they have the big bonus that they extend to 128 or 256 bit
operations without any further effort or specification...
-- 
(reverse (concatenate 'string ········@" "enworbbc"))
http://www.ntlug.org/~cbbrowne/x.html
Rules of the Evil Overlord  #211. "If my chief engineer displeases me,
he will be shot, not imprisoned  in the dungeon or beyond the traps he
helped design." <http://www.eviloverlord.com/>