

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object java.lang.Number org.openmali.types.primitives.MutableFloat
public class MutableFloat
This a mutable derivation of the Float
class.
Most of the code is borrowed from the Float
class.
Constructor Summary  

MutableFloat(double value)
Constructs a newly allocated MutableFloat object that
represents the argument converted to type float . 

MutableFloat(float value)
Constructs a newly allocated MutableFloat object that
represents the primitive float argument. 

MutableFloat(java.lang.String s)
Constructs a newly allocated MutableFloat object that
represents the floatingpoint value of type float
represented by the string. 
Method Summary  

byte 
byteValue()
Returns the value of this MutableFloat as a
byte (by casting to a byte ). 
int 
compareTo(MutableFloat anotherFloat)
Compares two MutableFloat objects numerically. 
double 
doubleValue()
Returns the double value of this
MutableFloat object. 
boolean 
equals(java.lang.Object obj)
Compares this object against the specified object. 
float 
floatValue()
Returns the float value of this MutableFloat
object. 
int 
hashCode()
Returns a hash code for this MutableFloat object. 
int 
intValue()
Returns the value of this MutableFloat as an
int (by casting to type int ). 
boolean 
isInfinite()
Returns true if this MutableFloat value is
infinitely large in magnitude, false otherwise. 
boolean 
isNaN()
Returns true if this MutableFloat value is a
NotaNumber (NaN), false otherwise. 
long 
longValue()
Returns value of this MutableFloat as a long
(by casting to type long ). 
void 
setValue(float value)

short 
shortValue()
Returns the value of this MutableFloat as a
short (by casting to a short ). 
java.lang.String 
toString()
Returns a string representation of this MutableFloat object. 
static MutableFloat 
valueOf(float f)
Returns a MutableFloat instance representing the specified float value. 
static MutableFloat 
valueOf(java.lang.String s)
Returns a MutableFloat object holding the
float value represented by the argument string
s . 
Methods inherited from class java.lang.Object 

clone, finalize, getClass, notify, notifyAll, wait, wait, wait 
Constructor Detail 

public MutableFloat(float value)
MutableFloat
object that
represents the primitive float
argument.
value
 the value to be represented by the MutableFloat
.public MutableFloat(double value)
MutableFloat
object that
represents the argument converted to type float
.
value
 the value to be represented by the MutableFloat
.public MutableFloat(java.lang.String s) throws java.lang.NumberFormatException
MutableFloat
object that
represents the floatingpoint value of type float
represented by the string. The string is converted to a
float
value as if by the valueOf
method.
s
 a string to be converted to a MutableFloat
.
java.lang.NumberFormatException
 if the string does not contain a
parsable number.Float.valueOf(java.lang.String)
Method Detail 

public final void setValue(float value)
public final boolean isNaN()
true
if this MutableFloat
value is a
NotaNumber (NaN), false
otherwise.
true
if the value represented by this object is
NaN; false
otherwise.public final boolean isInfinite()
true
if this MutableFloat
value is
infinitely large in magnitude, false
otherwise.
true
if the value represented by this object is
positive infinity or negative infinity;
false
otherwise.public java.lang.String toString()
MutableFloat
object.
The primitive float
value represented by this object
is converted to a String
exactly as if by the method
toString
of one argument.
toString
in class java.lang.Object
String
representation of this object.Float.toString(float)
public final byte byteValue()
MutableFloat
as a
byte
(by casting to a byte
).
byteValue
in class java.lang.Number
float
value represented by this object
converted to type byte
public final short shortValue()
MutableFloat
as a
short
(by casting to a short
).
shortValue
in class java.lang.Number
float
value represented by this object
converted to type short
public final int intValue()
MutableFloat
as an
int
(by casting to type int
).
intValue
in class java.lang.Number
float
value represented by this object
converted to type int
public final long longValue()
MutableFloat
as a long
(by casting to type long
).
longValue
in class java.lang.Number
float
value represented by this object
converted to type long
public final float floatValue()
float
value of this MutableFloat
object.
floatValue
in class java.lang.Number
float
value represented by this objectpublic double doubleValue()
double
value of this
MutableFloat
object.
doubleValue
in class java.lang.Number
float
value represented by this
object is converted to type double
and the
result of the conversion is returned.public int hashCode()
MutableFloat
object. The
result is the integer bit representation, exactly as produced
by the method Float.floatToIntBits(float)
, of the primitive
float
value represented by this MutableFloat
object.
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
true
if and only if the argument is not
null
and is a Float
object that
represents a float
with the same value as the
float
represented by this object. For this
purpose, two float
values are considered to be the
same if and only if the method Float.floatToIntBits(float)
returns the identical int
value when applied to
each.
Note that in most cases, for two instances of class
Float
, f1
and f2
, the value
of f1.equals(f2)
is true
if and only if
f1.floatValue() == f2.floatValue()
also has the value true
. However, there are two exceptions:
f1
and f2
both represent
Float.NaN
, then the equals
method returns
true
, even though Float.NaN==Float.NaN
has the value false
.
f1
represents +0.0f
while
f2
represents 0.0f
, or vice
versa, the equal
test has the value
false
, even though 0.0f==0.0f
has the value true
.
equals
in class java.lang.Object
obj
 the object to be compared
true
if the objects are the same;
false
otherwise.Float.floatToIntBits(float)
public int compareTo(MutableFloat anotherFloat)
MutableFloat
objects numerically. There are
two ways in which comparisons performed by this method differ
from those performed by the Java language numerical comparison
operators (<, <=, ==, >= >
) when
applied to primitive float
values:
Float.NaN
is considered by this method to
be equal to itself and greater than all other
float
values
(including Float.POSITIVE_INFINITY
).
0.0f
is considered by this method to be greater
than 0.0f
.
compareTo
in interface java.lang.Comparable<MutableFloat>
anotherFloat
 the Float
to be compared.
0
if anotherFloat
is
numerically equal to this MutableFloat
; a value
less than 0
if this MutableFloat
is numerically less than anotherFloat
;
and a value greater than 0
if this
MutableFloat
is numerically greater than
anotherFloat
.Comparable.compareTo(Object)
public static MutableFloat valueOf(java.lang.String s) throws java.lang.NumberFormatException
MutableFloat
object holding the
float
value represented by the argument string
s
.
If s
is null
, then a
NullPointerException
is thrown.
Leading and trailing whitespace characters in s
are ignored. Whitespace is removed as if by the String.trim()
method; that is, both ASCII space and control
characters are removed. The rest of s
should
constitute a FloatValue as described by the lexical
syntax rules:
where Sign, FloatingPointLiteral, HexNumeral, HexDigits, SignedInteger and FloatTypeSuffix are as defined in the lexical structure sections of the of the Java Language Specification. If
 FloatValue:
 Sign_{opt}
NaN
 Sign_{opt}
Infinity
 Sign_{opt} FloatingPointLiteral
 Sign_{opt} HexFloatingPointLiteral
 SignedInteger
 HexFloatingPointLiteral:
 HexSignificand BinaryExponent FloatTypeSuffix_{opt}
 HexSignificand:
 HexNumeral
 HexNumeral
.
0x
HexDigits_{opt}.
HexDigits0X
HexDigits_{opt}.
HexDigits
 BinaryExponent:
 BinaryExponentIndicator SignedInteger
 BinaryExponentIndicator:
p
P
s
does not have the form of
a FloatValue, then a NumberFormatException
is thrown. Otherwise, s
is regarded as
representing an exact decimal value in the usual
"computerized scientific notation" or as an exact
hexadecimal value; this exact numerical value is then
conceptually converted to an "infinitely precise"
binary value that is then rounded to type float
by the usual roundtonearest rule of IEEE 754 floatingpoint
arithmetic, which includes preserving the sign of a zero
value. Finally, a MutableFloat
object representing this
float
value is returned.
To interpret localized string representations of a floatingpoint value, use subclasses of java.text.NumberFormat.
Note that trailing format specifiers, specifiers that
determine the type of a floatingpoint literal
(1.0f
is a float
value;
1.0d
is a double
value), do
not influence the results of this method. In other
words, the numerical value of the input string is converted
directly to the target floatingpoint type. In general, the
twostep sequence of conversions, string to double
followed by double
to float
, is
not equivalent to converting a string directly to
float
. For example, if first converted to an
intermediate double
and then to
float
, the string
"1.00000017881393421514957253748434595763683319091796875001d"
results in the float
value
1.0000002f
; if the string is converted directly to
float
, 1.0000001f
results.
To avoid calling this method on a invalid string and having
a NumberFormatException
be thrown, the documentation
for Double.valueOf(String)
lists a regular
expression which can be used to screen the input.
s
 the string to be parsed.
MutableFloat
object holding the value
represented by the String
argument.
java.lang.NumberFormatException
 if the string does not contain a
parsable number.public static MutableFloat valueOf(float f)
MutableFloat(float)
, as this method is likely to yield
significantly better space and time performance by caching
frequently requested values.
f
 a float value.


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 