[futurebasic] Re: fun for thought

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 1998 : Group Archive : Group : All Groups

From: jonathan <jonathan@...>
Date: Mer, 30 Sep 98 09:47:00 +0200
>Jonathan said:
>
>>>A bit-twiddler however will see them as 16 continous bit spaces in memory
>that can contain 16 different boolean states, but they can be even more than
>that!<<
>
>OK, how 'bout this: Suppose I have a whole bunch of variables that are just
>one-bit toggles: on/off, true/false, yes/no. If I wanted to pare unused 
>memory
>to an absolute minimum, could I pack them 16 at a time into a single integer
>variable and pick out the bit I want? For example:
>
>  IF monsterVar% AND 2^n THEN FN doMyStuff(n)

Yep, you've just discovered the immense fun of bit-twiddling Lucy
( a wonderful hobby for all the family :-), or I do it with constants:
_fred    = &8000
_albert  = &4000
_rene    = &2000
_robert  = &1000
_charles = &0800
'.. and so on
IF( gMonsterVar% AND _robert) THEN doItForLucy( _robert)

jonathan



-------------------------------------------------------------
! "format utile"  studio de graphisme/graphic design studio !
!      32 bd de Menilmontant, 75020 Paris, France           !
!    phone +33 1 43 49 02 04 +++ fax +33 1 43 49 16 51      !
-------------------------------------------------------------
           *** coming soon to a browser near you ***
           <http://www.cybercities.com/formatutile>
-------------------------------------------------------------