[futurebasic] Re: fun for thought

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

From: Rick Brown <rbrown@...>
Date: Tue, 29 Sep 1998 20:21:56 -0500
Lucy wrote:
> 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)

Yes indeed.  But it would be more efficient to do the comparison like
this:

    IF monsterVar% AND BIT(n) THEN FN doMyStuff(n)

because "2^n" invokes some nasty time-consuming exponential math
calculations, while BIT(n) does not.

- Rick