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)
-
ConvertableBitSet()
-
-
ConvertableBitSet(int)
- Contructs a BitSet object with given number of bits, all set to
zero.
-
and(BitSet)
- Logically ANDs current ConvertableBitSet with the specified
BitSet.
-
and(ConvertableBitSet)
- Logically ANDs current ConvertableBitSet with the specified
ConvertableBitSet.
-
clear(int)
- Sets the given bit to zero (or false).
-
clone()
-
-
equals(Object)
-
-
fromDouble(double)
- Returns the bitset representation of the specified floating-point value according
to the IEEE 754 floating-point "double format" bit layout.
-
fromFloat(float)
- Returns the bitset represention of a single-float value.
-
fromInt(int)
-
-
fromLong(long)
-
-
fromString(String)
-
-
get(int)
- Returns the value of the given bit.
-
hashCode()
-
-
or(BitSet)
- Logically ORs current ConvertableBitSet with the specified
BitSet.
-
or(ConvertableBitSet)
- Logically ORs current ConvertableBitSet with the specified
ConvertableBitSet.
-
set(int)
- Sets the given bit to one (or true).
-
size()
- Returns the number of bits in the ConvertableBitSet.
-
toDouble()
- Constucts a double from the bitset.
-
toDoubleString()
- Return a string representation of the ConvertableBitSet as if it represented
a double.
-
toFloat()
- Constucts a float from the bitset.
-
toFloatString()
- Return a string representation of the ConvertableBitSet as if it represented
a float.
-
toInt()
- Constucts an int from the bitset.
-
toLong()
- Constucts an int from the bitset.
-
toString()
- Returns a string representation of the bitset.
-
toString(int)
- Returns a String representation of the bitset using the first
numberOfBits of the bitset.
-
xor(BitSet)
- Logically XORs current ConvertableBitSet with the specified
BitSet.
-
xor(ConvertableBitSet)
- Logically XORs current ConvertableBitSet with the specified
ConvertableBitSet.
ConvertableBitSet
public ConvertableBitSet()
ConvertableBitSet
public ConvertableBitSet(int size)
- Contructs a BitSet object with given number of bits, all set to
zero.
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
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.
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.
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".
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.
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.
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.
toInt
public int toInt()
- Constucts an int from the bitset. Only the first 32 bits
in the BitSet are used.
toLong
public int toLong()
- Constucts an int from the bitset. Only the first 64 bits
in the BitSet are used.
and
public void and(ConvertableBitSet set)
- Logically ANDs current ConvertableBitSet with the specified
ConvertableBitSet.
and
public void and(BitSet set)
- Logically ANDs current ConvertableBitSet with the specified
BitSet.
or
public void or(BitSet set)
- Logically ORs current ConvertableBitSet with the specified
BitSet.
or
public void or(ConvertableBitSet set)
- Logically ORs current ConvertableBitSet with the specified
ConvertableBitSet.
xor
public void xor(BitSet set)
- Logically XORs current ConvertableBitSet with the specified
BitSet.
xor
public void xor(ConvertableBitSet set)
- Logically XORs current ConvertableBitSet with the specified
ConvertableBitSet.
clear
public void clear(int bit)
- Sets the given bit to zero (or false).
get
public boolean get(int bit)
- Returns the value of the given bit.
set
public void set(int bit)
- Sets the given bit to one (or true).
hashCode
public int hashCode()
- Overrides:
- hashCode in class Object
size
public int size()
- Returns the number of bits in the ConvertableBitSet.
equals
public boolean equals(Object anObject)
- Overrides:
- equals in class Object
clone
public Object clone()
- Overrides:
- clone in class Object
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
toString
public String toString(int numberOfBits)
- Returns a String representation of the bitset using the first
numberOfBits of the bitset.
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).
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