frysk.gui.common
Class UBigInteger

java.lang.Object
  extended by frysk.gui.common.UBigInteger

public class UBigInteger
extends Object

Some utility functions for treating BigIntegers as unsigned integers.


Constructor Summary
UBigInteger()
           
 
Method Summary
private static BigInteger makeMask(int integerLength)
           
static BigInteger mask(BigInteger val, int integerLength)
          Mask off the lower bits of a BigInteger, replacing the upper bits with zeros (obviously).
static BigInteger signExtend(BigInteger val, int integerLength)
          Treat the MSB of an unsigned integer stored in a BigInteger as a sign bit and return a positive or negative BigInteger as appropriate.
static String toString(BigInteger val, int integerLength, int radix)
          Print the string representation of an unsigned integer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UBigInteger

public UBigInteger()
Method Detail

makeMask

private static BigInteger makeMask(int integerLength)

mask

public static BigInteger mask(BigInteger val,
                              int integerLength)
Mask off the lower bits of a BigInteger, replacing the upper bits with zeros (obviously).

Parameters:
val - BigInteger value
integerLength - length of bits to preserve
Returns:
masked value.

toString

public static String toString(BigInteger val,
                              int integerLength,
                              int radix)
Print the string representation of an unsigned integer.

Parameters:
val - the BigInteger holding the unsigned integer
integerLength - length of unsigned integer
radix - of output
Returns:
string represntation

signExtend

public static BigInteger signExtend(BigInteger val,
                                    int integerLength)
Treat the MSB of an unsigned integer stored in a BigInteger as a sign bit and return a positive or negative BigInteger as appropriate.

Parameters:
val - the BigInteger value
integerLength - length of unsigned integer, or 1 plus bit position of sign bit.
Returns:
new integer with proper sign.