Float class
Float class wraps a value of type float in an object.
Field Summary
static int MAX_EXPONENT
- Maximum exponent a finite float.
static float MAX_VALUE
- Largest positive finite value of type float.
static int MIN_EXPONENT
- Minimum exponent a normalized float variable may have.
static float MIN_NORMAL
- Smallest positive normal value of type float.
static float MIN_VALUE
- Smallest positive nonzero value of type float.
static float NaN
- Not-a-Number (NaN) value of type float.
static float NEGATIVE_INFINITY
- Negative infinity of type float.
static float POSITIVE_INFINITY
- Positive infinity of type float.
static int SIZE
- The number of bits used to represent a float value.
static Class TYPE
- The Class instance representing the primitive type float.
Constructor
Float(double value)
- Creates a Float from double-type value.
Float(float value)
- Creates a Float for the float argument.
Float(String s)
- Creates a Float from a float represented by the string.
Convert to byte, double, float, int, long and short
byte byteValue()
- Returns this float as a byte.
double doubleValue()
- Returns the double value.
float floatValue()
- Returns the float value.
int intValue()
- Returns this float as an int by casting to type int.
long longValue()
- Returns this float as a long.
short shortValue()
- Returns this float as a short by casting.
Convert float value to String value
static String toHexString(float f)
- Returns a hexadecimal string representation of the float argument.
String toString()
- Returns a string representation of this Float object.
static String toString(float f)
- Returns a string representation of the float argument.
Convert string value to float value
static float parseFloat(String s)
- Returns a new float initialized to the value represented by the specified String.
static Float valueOf(float f)
- Returns a Float instance representing the specified float value.
static Float valueOf(String s)
- Returns a Float object holding the float value represented by the argument string s.
Compare two float objects
static int compare(float f1, float f2)
- Compares the two specified float values.
int compareTo(Float anotherFloat)
- Compares two Float objects numerically.
boolean equals(Object obj)
- Compares this object against the specified object.
Infinite and NaN(Not A Number)
boolean isInfinite()
- Returns true if this Float value is infinitely large in magnitude, false otherwise.
static boolean isInfinite(float v)
- Returns true if the specified number is infinitely large in magnitude, false otherwise.
boolean isNaN()
- Returns true if this Float value is a Not-a-Number (NaN), false otherwise.
static boolean isNaN(float v)
- Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.
Bit oriented
static int floatToIntBits(float value)
- Returns a representation of the specified floating-point value.
static int floatToRawIntBits(float value)
- Returns a representation of the specified floating-point value.
static float intBitsToFloat(int bits)
- Returns the float value corresponding to a given bit representation.
Home
Java Book
Essential Classes
Java Book
Essential Classes
Float:
- Float class
- MAX/MIN_VALUE Find out the Maximum value and Minimum value a float type can have
- Create a Float object
- Convert Float to byte, double, float, int, long and short
- Compare two float objects
- Infinite and Not A Number
- Convert float value to Hex String value
- Convert float value to String value
- Convert string value to float value
- Bit oriented calculation for float