Database Management and Java

By Art Sulger

Dr. Dobb's Journal May 1997

	(a)
	static final int RSN = 13;//bit number 13 in the set 
	static final int TIMESTAMP  = 21;//bit number 21 . . .
	BitSet ColType = new BitSet(26);//a set of 26 bits
	ColType.set(RSN);// set the 13th bit 
	ColType.set(TIMESTAMP);// set the 21st bit 
	// do something if column is RSN or TIMESTAMP: 
	if (ColType.get(RSN) | ColType.get(TIMESTAMP)) ...
	(b)
	enum eElementType {
	 . . .  
	RSN      =0x1000,    //bit 13 (00000000001000000000000)
	TIMESTAMP=0x00100000,//bit 21 (00100000000000000000000)
	 . . . }ColType; 
	ColType = RSN & TIMESTAMP; // makes the assignment 
	if (ColType & (RSN | TIMESTAMP))...

Example 2: (a) Java bit comparisons; (b) C++ bit comparisons.

Back to Article


Copyright © 1997, Dr. Dobb's Journal