"

2013 FRC Java API

"

java.lang
Class Float

java.lang.Object
  extended by java.lang.Float

public final class Float
extends Object

The Float class provides an object wrapper for Float data values, and serves as a place for float-oriented operations. A wrapper is useful because most of Java's utility classes require the use of objects. Since floats are not objects in Java, they need to be "wrapped" in a Float instance.

Version:
1.32, 22 Dec 1995

Field Summary
static float MAX_VALUE
          The maximum value a float can have.
static float MIN_VALUE
          The minimum value a float can have.
static float NaN
          Not-a-Number.
static float NEGATIVE_INFINITY
          Negative infinity.
static float POSITIVE_INFINITY
          Positive infinity.
 
Constructor Summary
Float(double value)
          Constructs a Float wrapper for the specified double value.
Float(float value)
          Constructs a Float wrapper for the specified float value.
 
Method Summary
 byte byteValue()
          Returns the value of this Float as a byte (by casting to a byte).
 double doubleValue()
          Returns the double value of this Float.
 boolean equals(Object obj)
          Compares this object against some other object.
static int floatToIntBits(float value)
          Returns the bit represention of a single-float value
 float floatValue()
          Returns the float value of this Float object.
 int hashCode()
          Returns a hashcode for this Float.
static float intBitsToFloat(int bits)
          Returns the single-float corresponding to a given bit represention.
 int intValue()
          Returns the integer value of this Float (by casting to an int).
 boolean isInfinite()
          Returns true if this Float value is infinitely large in magnitude.
static boolean isInfinite(float v)
          Returns true if the specified number is infinitely large in magnitude.
 boolean isNaN()
          Returns true if this Float value is Not-a-Number (NaN).
static boolean isNaN(float v)
          Returns true if the specified number is the special Not-a-Number (NaN) value.
 long longValue()
          Returns the long value of this Float (by casting to a long).
static float parseFloat(String s)
          Returns a new float initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
 short shortValue()
          Returns the value of this Float as a short (by casting to a short).
 String toString()
          Returns a String representation of this Float object.
static String toString(float f)
          Returns a String representation for the specified float value.
static Float valueOf(float val)
           
static Float valueOf(String s)
          Returns the floating point value represented by the specified String.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

POSITIVE_INFINITY

public static final float POSITIVE_INFINITY
Positive infinity.

See Also:
Constant Field Values

NEGATIVE_INFINITY

public static final float NEGATIVE_INFINITY
Negative infinity.

See Also:
Constant Field Values

NaN

public static final float NaN
Not-a-Number. Is not equal to anything, including itself.

See Also:
Constant Field Values

MAX_VALUE

public static final float MAX_VALUE
The maximum value a float can have. The largest maximum value possible is 3.40282346638528860e+38.

See Also:
Constant Field Values

MIN_VALUE

public static final float MIN_VALUE
The minimum value a float can have. The lowest minimum value possible is 1.40129846432481707e-45.

See Also:
Constant Field Values
Constructor Detail

Float

public Float(float value)
Constructs a Float wrapper for the specified float value.

Parameters:
value - the value of the Float

Float

public Float(double value)
Constructs a Float wrapper for the specified double value.

Parameters:
value - the value of the Float
Method Detail

toString

public static String toString(float f)
Returns a String representation for the specified float value.

Parameters:
f - the float to be converted

valueOf

public static Float valueOf(String s)
                     throws NumberFormatException
Returns the floating point value represented by the specified String.

Parameters:
s - the String to be parsed
Throws:
NumberFormatException - If the String does not contain a parsable Float.

isNaN

public static boolean isNaN(float v)
Returns true if the specified number is the special Not-a-Number (NaN) value.

Parameters:
v - the value to be tested

isInfinite

public static boolean isInfinite(float v)
Returns true if the specified number is infinitely large in magnitude.

Parameters:
v - the value to be tested

parseFloat

public static float parseFloat(String s)
                        throws NumberFormatException
Returns a new float initialized to the value represented by the specified String, as performed by the valueOf method of class Double.

Parameters:
s - the string to be parsed.
Returns:
the float value represented by the string argument.
Throws:
NumberFormatException - if the string does not contain a parsable float.
Since:
JDK1.2
See Also:
Double.valueOf(String)

isNaN

public boolean isNaN()
Returns true if this Float value is Not-a-Number (NaN).


isInfinite

public boolean isInfinite()
Returns true if this Float value is infinitely large in magnitude.


toString

public String toString()
Returns a String representation of this Float object.

Overrides:
toString in class Object
Returns:
a string representation of the object.

byteValue

public byte byteValue()
Returns the value of this Float as a byte (by casting to a byte).


shortValue

public short shortValue()
Returns the value of this Float as a short (by casting to a short).


intValue

public int intValue()
Returns the integer value of this Float (by casting to an int).


longValue

public long longValue()
Returns the long value of this Float (by casting to a long).


floatValue

public float floatValue()
Returns the float value of this Float object.


doubleValue

public double doubleValue()
Returns the double value of this Float.


hashCode

public int hashCode()
Returns a hashcode for this Float.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), Hashtable

equals

public boolean equals(Object obj)
Compares this object against some other object. To be useful in hashtables this method considers two Nan floating point values to be equal. This is not according to IEEE specification.

Overrides:
equals in class Object
Parameters:
obj - the object to compare with
Returns:
true if the objects are the same; false otherwise.
See Also:
Boolean.hashCode(), Hashtable

floatToIntBits

public static int floatToIntBits(float value)
Returns the bit represention of a single-float value


intBitsToFloat

public static float intBitsToFloat(int bits)
Returns the single-float corresponding to a given bit represention.


valueOf

public static Float valueOf(float val)

"

2013 FRC Java API

"

"
For updated information see the Java FRC site
"