Re: Code thats out there!

From: jaco v Iterson (strider@guyot.ptf.hro.nl)
Date: 06/19/95


> 
> On Thu, 15 Jun 1995, Giao H Phan wrote:
> 
> > on wizbits, as an aside to hex, have you guys started using that idea 
> > whereby you could stuff like 80 bits into one var? i heard some bits and 
> > pieces from pythe or fred about some sorta linked long shit or somethin, 
> > i dunno... wonderin anything ever came of that, and if so, what? ;}
> 
> I haven't heard of 'em at all..unless you're talking about a long 
> double.  I know under Borland C's DOS compiler, a long double is 80 bits, 
> but I was under the impression that it wasn't ANSI, portable, or even 
> especially kosher for use in everyday code.  You could also just use an 
> array of long[2] and write an intelligent function-like macro to figure 
> out which long to compare with, but you'll run smack up against word 
> ordering on different machines, as well as the cases where you need to 
> check bits from both elements of the array.
> 
> 
>  _/\_   GU -d H s : g? p5 au- a17 w v- C UL P L 3- E---- N K- W--- M-- V-- po
> / L  \  Y t 5 j-- R G---- tv-- b D B--- e u*(**) h! f !r !n !y+   
> \_ C_/  =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>   \/    My life as an instruction: xchg   al,al
> 
> I have great faith in fools -- self confidence my friends call it.
> 		-- Edgar Allan Poe
> 
> 
A bitlist can be used. it goes something like:

struct bits {
  unsigned bit1 :1,
  unsigned bit2 :1,
  unsigned bit3 :1
};

It is ansi but I'm not sure if i got the syntax right.
The :1 means the var is 1 bit long in memory
(it has to be unsigned if it's 1 bit)
It could be :2 too (maybe for syslog1 and syslog2)
You now also can use something like:
if (bits.bit3) {
.....
}
instead of 
if (GET_BIT(bitvector, 3)) {
....
}

If you want to use both systems you can use something like
union bitunion {
  struct bits,
  long int bitvector
};

(again i'm not sure of the syntax, check your C-book)


This way the struck and the long int ocupy the same space in memory so
if you change the one, the other is changed automaticly (since they are the same)



This archive was generated by hypermail 2b30 : 12/18/00 PST