All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sdsu.util.ConvertableBitSet

java.lang.Object
   |
   +----sdsu.util.ConvertableBitSet

public final class ConvertableBitSet
extends Object
implements Cloneable, Serializable
This class extends the functionality of java.util.BitSet. Since java.util.BitSet is a final class, ConvertableBitSet is not a subclass of java.util.BitSet. It adds the ablity to convert between basic types (ints, float) and BitSet objects.

Version:
1.0 5 January 1999
Author:
Roger Whitney (whitney@cs.sdsu.edu)

Constructor Index

 o ConvertableBitSet()
 o ConvertableBitSet(int)
Contructs a BitSet object with given number of bits, all set to zero.

Method Index

 o and(BitSet)
Logically ANDs current ConvertableBitSet with the specified BitSet.
 o and(ConvertableBitSet)
Logically ANDs current ConvertableBitSet with the specified ConvertableBitSet.
 o clear(int)
Sets the given bit to zero (or false).
 o clone()
 o equals(Object)
 o fromDouble(double)
Returns the bitset representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout.
 o fromFloat(float)
Returns the bitset represention of a single-float value.
 o fromInt(int)
 o fromLong(long)
 o fromString(String)
 o get(int)
Returns the value of the given bit.
 o hashCode()
 o or(BitSet)
Logically ORs current ConvertableBitSet with the specified BitSet.
 o or(ConvertableBitSet)
Logically ORs current ConvertableBitSet with the specified ConvertableBitSet.
 o set(int)
Sets the given bit to one (or true).
 o size()
Returns the number of bits in the ConvertableBitSet.
 o toDouble()
Constucts a double from the bitset.
 o toDoubleString()
Return a string representation of the ConvertableBitSet as if it represented a double.
 o toFloat()
Constucts a float from the bitset.
 o toFloatString()
Return a string representation of the ConvertableBitSet as if it represented a float.
 o toInt()
Constucts an int from the bitset.
 o toLong()
Constucts an int from the bitset.
 o toString()
Returns a string representation of the bitset.
 o toString(int)
Returns a String representation of the bitset using the first numberOfBits of the bitset.
 o xor(BitSet)
Logically XORs current ConvertableBitSet with the specified BitSet.
 o xor(ConvertableBitSet)
Logically XORs current ConvertableBitSet with the specified ConvertableBitSet.

Constructors

 o ConvertableBitSet
 public ConvertableBitSet()
 o ConvertableBitSet
 public ConvertableBitSet(int size)
Contructs a BitSet object with given number of bits, all set to zero.

Methods

 o fromString
 public static ConvertableBitSet fromString(String bits)
Parameters:
bits - a string representation of the bits. All characters in the string must be '0' or '1'. The low order bit is on the right end of the string
 o fromInt
 public static ConvertableBitSet fromInt(int value)
Returns:
A bitset that represents the bit pattern of the int "value" The low order bit in the int is bit zero in the bitset.
 o fromLong
 public static ConvertableBitSet fromLong(long value)
Returns:
A bitset that represents the bit pattern of the long "value". The low order bit in the long is bit zero in the bitset.
 o fromFloat
 public static ConvertableBitSet fromFloat(float value)
Returns the bitset represention of a single-float value. The result is a representation of the floating-point argument according to the IEEE 754 floating-point "single precision" bit layout.

Bit 31 represents the sign of the floating-point number. Bits 30-23 represent the exponent. Bits 22-0 represent the mantissa (or significand) of the floating-point number.

If the argument is positive infinity, the result is 0x7f800000.
If the argument is negative infinity, the result is 0xff800000.
If the argument is NaN, the result is 0x7fc00000.

Returns:
A bitset that represents the bit pattern of the float "value".
 o fromDouble
 public static ConvertableBitSet fromDouble(double value)
Returns the bitset representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout.

Bit 63 represents the sign of the floating-point number. Bits 62-52 represent the exponent. Bits 51-0 represent the mantissa or significand of the floating-point number.

If the argument is positive infinity, the result is 0x7ff0000000000000L.
If the argument is negative infinity, the result is 0xfff0000000000000L.
If the argument is NaN, the result is 0x7ff8000000000000L.

 o toFloat
 public float toFloat()
Constucts a float from the bitset. Uses the IEEE 754 floating-point "single precision" bit layout to construct the float. Only the first 32 bits in the BitSet are used.

 o toDouble
 public double toDouble()
Constucts a double from the bitset. Uses the IEEE 754 floating-point "double format" bit layout to construct the float. Only the first 64 bits in the BitSet are used.

 o toInt
 public int toInt()
Constucts an int from the bitset. Only the first 32 bits in the BitSet are used.

 o toLong
 public int toLong()
Constucts an int from the bitset. Only the first 64 bits in the BitSet are used.

 o and
 public void and(ConvertableBitSet set)
Logically ANDs current ConvertableBitSet with the specified ConvertableBitSet.

 o and
 public void and(BitSet set)
Logically ANDs current ConvertableBitSet with the specified BitSet.

 o or
 public void or(BitSet set)
Logically ORs current ConvertableBitSet with the specified BitSet.

 o or
 public void or(ConvertableBitSet set)
Logically ORs current ConvertableBitSet with the specified ConvertableBitSet.

 o xor
 public void xor(BitSet set)
Logically XORs current ConvertableBitSet with the specified BitSet.

 o xor
 public void xor(ConvertableBitSet set)
Logically XORs current ConvertableBitSet with the specified ConvertableBitSet.

 o clear
 public void clear(int bit)
Sets the given bit to zero (or false).

 o get
 public boolean get(int bit)
Returns the value of the given bit.

 o set
 public void set(int bit)
Sets the given bit to one (or true).

 o hashCode
 public int hashCode()
Overrides:
hashCode in class Object
 o size
 public int size()
Returns the number of bits in the ConvertableBitSet.

 o equals
 public boolean equals(Object anObject)
Overrides:
equals in class Object
 o clone
 public Object clone()
Overrides:
clone in class Object
 o toString
 public String toString()
Returns a string representation of the bitset. Includes one bit beyond the highest order one (true) bit.

Overrides:
toString in class Object
 o toString
 public String toString(int numberOfBits)
Returns a String representation of the bitset using the first numberOfBits of the bitset.

 o toFloatString
 public String toFloatString()
Return a string representation of the ConvertableBitSet as if it represented a float. A "," separates the bit that represent the sign bit (bit 31), the bits that represent the exponent (bits 30-23) and the bits that represent the mantissa (or significand) (bits 22-0).

 o toDoubleString
 public String toDoubleString()
Return a string representation of the ConvertableBitSet as if it represented a double. A "," separates the bit that represent the sign bit (bit 63), the bits that represent the exponent (bits 62-52) and the bits that represent the mantissa (or significand) (bits 51-0).


All Packages  Class Hierarchy  This Package  Previous  Next  Index