swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] binary numbers


From: Paul Johnson
Subject: Re: [Swarm-Support] binary numbers
Date: Tue, 08 Jul 2003 09:33:24 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225

I wrote classes to do this for the artificial stock market http://ArtStkMkt.sourceforge.net.

pj

Marcello wrote:
Thanks for the replies. Which kind of type should bitstring be in order
to work with standard bit operators?
marcello
On Tue, 2003-07-08 at 12:45, Russell Standish wrote:

If the bitstrings fit into the system wordsize (32 bits on average
PCs), then you can use the standard bit manipulation operators of C:

x|=1<<i    - sets the ith bit of x
(x&1<<i)!=0     - returns the ith bit of 0

If you have more bits than the wordsize, then you'll need to concoct a
BitSet object to do your work. C++ has a number of these - I'm not so
familiar with what's available for Obj C.

                                        Cheers



--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700



reply via email to

[Prev in Thread] Current Thread [Next in Thread]