nars.entity
Class ShortFloat

java.lang.Object
  extended by nars.entity.ShortFloat
All Implemented Interfaces:
java.lang.Cloneable

public class ShortFloat
extends java.lang.Object
implements java.lang.Cloneable

A float value in [0, 1], with 4 digits accuracy.


Field Summary
private  short value
          To save space, the values are stored as short integers (-32768 to 32767, only 0 to 10000 used), but used as float
 
Constructor Summary
ShortFloat(float v)
          Constructor
 
Method Summary
 boolean equals(java.lang.Object that)
          Compare two ShortFloat values
(package private)  short getShortValue()
          To access the value as short
 float getValue()
          To access the value as float
 int hashCode()
          The hash code of the ShortFloat
 void setValue(float v)
          Set new value, rounded, with validity checking
 java.lang.String toString()
          Convert the value into a String
 java.lang.String toString2()
          Round the value into a short String
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

private short value
To save space, the values are stored as short integers (-32768 to 32767, only 0 to 10000 used), but used as float

Constructor Detail

ShortFloat

public ShortFloat(float v)
Constructor

Parameters:
v - The initial value
Method Detail

getValue

public float getValue()
To access the value as float

Returns:
The current value in float

getShortValue

short getShortValue()
To access the value as short

Returns:
The current value in short

setValue

public void setValue(float v)
Set new value, rounded, with validity checking

Parameters:
v - The new value

equals

public boolean equals(java.lang.Object that)
Compare two ShortFloat values

Overrides:
equals in class java.lang.Object
Parameters:
that - The other value to be compared
Returns:
Whether the two have the same value

hashCode

public int hashCode()
The hash code of the ShortFloat

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code

toString

public java.lang.String toString()
Convert the value into a String

Overrides:
toString in class java.lang.Object
Returns:
The String representation, with 4 digits accuracy

toString2

public java.lang.String toString2()
Round the value into a short String

Returns:
The String representation, with 2 digits accuracy