On Sat, 9 Dec 1995, Paul Cole wrote: > FLAG -- a STATE <example of uses in *mud, FLYING, > BITVECTOR -- a variable which can repreresent one or more FLAGS or STATES. > A flag isn't a state, a flag has 2 states, on or off, 2 flags have 4 states, off-off, off-on, on-off, off-off, etc. > An 8 bit field can represent only 8 states or flags normally. That would be 256 states or 8 flags. > > For example > Suppose you have 4 bits you want to represent SWIMMING, DIVING, > WALKING, RUNNING > > Normal straight forward method would be to use 4 bits to control these > flags or states. > > SDWR <1000 is swimming, 0001 is running> > > But close inspection would show that you can use a mere 2 bits for these 4 > values becuase RUNNING is only possible when you are WALKING and DIVING is > only possible when you are SWIMMING. Also, I note that WALKING is the same > thing as NOT FLYING. So you could <though I don't, too much work> use 2 > bits to represent this. > > XY where > X -- 1 = SWIMMING, 0 = WALKING > Y -- 1 = DIVING, 0 = RUNNING > or 00 = NOT SWIMMING and NOT RUNNNING = WALKING > 01 = NOT SWIMMING and RUNNING > 10 = SWIMMING and NOT DIVING > 11 = SWIMMING and DIVING > > Thus I've just implemented all 4 STATES in 2 BITS. What you are doing here is deleting unused states, first you had 16 posible states of which only 4 were actualy used. Getting rid of unused states is always a good idea. > > This is very proprietary and imho, not terribly useful. It is only > presented here as a method for representing more than X FLAGS in an Xbit > bit field. It is a very good method, only I think you are representing x flags in an x bit bitfield after the method is used and was using to many bits before. Jaco
This archive was generated by hypermail 2b30 : 12/07/00 PST