|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectRepresentation
class Representation
A class that holds a representation of a binary number along with assorted metadata about the number. Two representations are needed to hold a fixed point number. Ints are used for each bit so each can take on the values of 1, 0 or -1. -1 values come into play for CSD numbers.
Field Summary | |
---|---|
private boolean |
guardBit
|
private int |
numberBits
|
private int[] |
representation
|
private boolean |
signBit
|
Constructor Summary | |
---|---|
Representation(int numberBits)
Class constructor creates storage for the representation of the specified number of bits and sets the the two bits of metadata to false. |
Method Summary | |
---|---|
java.lang.String |
formatRepresentation(boolean showMetadata)
|
private void |
fromLong(long value)
Make the representation conform to the long value |
int |
getBit(int bitNumber)
|
boolean |
getGuardBit()
|
int |
getNumberBits()
|
int[] |
getRepresentation()
|
boolean |
getSignBit()
|
void |
onesComp()
Performs a 1's compliment operation on the representation. |
void |
setBit(int bitNumber,
int bit)
|
void |
setGuardBit(boolean guardBit)
|
void |
setRepresentation(int[] representation)
|
void |
setSignBit(boolean signBit)
|
private long |
toLong()
Create a long value from the representation |
java.lang.String |
toString()
|
void |
twosComp()
Performs a 2's compliment operation on the representation. |
boolean |
zero()
Determine if the representation has no bits set |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private int numberBits
private boolean signBit
private boolean guardBit
private int[] representation
Constructor Detail |
---|
public Representation(int numberBits)
numberBits
- number of bits in the representationMethod Detail |
---|
public boolean zero()
public void onesComp()
private long toLong()
private void fromLong(long value)
value
- long value that the representation should conform topublic void twosComp()
public int getNumberBits()
public boolean getSignBit()
public void setSignBit(boolean signBit)
public boolean getGuardBit()
public void setGuardBit(boolean guardBit)
public int[] getRepresentation()
public void setRepresentation(int[] representation)
public int getBit(int bitNumber)
public void setBit(int bitNumber, int bit)
public java.lang.String formatRepresentation(boolean showMetadata)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |