public final class Float extends Number implements Comparable<Float>
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_EXPONENT |
static float |
MAX_VALUE |
static int |
MIN_EXPONENT |
static float |
MIN_NORMAL |
static float |
MIN_VALUE |
static float |
NaN |
static float |
NEGATIVE_INFINITY |
static float |
POSITIVE_INFINITY |
static int |
SIZE |
static Class<?> |
TYPE |
| Constructor and Description |
|---|
Float(double value) |
Float(float value)
Constructs a newly allocated Float object that represents the primitive float argument.
|
Float(String s) |
| Modifier and Type | Method and Description |
|---|---|
byte |
byteValue()
Return the byte value of this Number.
|
static int |
compare(float a,
float b) |
int |
compareTo(Float other)
Compares this with another Object.
|
double |
doubleValue()
Return the double value of this Number.
|
boolean |
equals(Object o) |
static int |
floatToIntBits(float value)
Returns the bit representation of a single-float value.
|
static int |
floatToRawIntBits(float value)
Returns the bit representation of a single-float value.
|
float |
floatValue()
Returns the float value of this Float object.
|
int |
hashCode() |
static float |
intBitsToFloat(int value)
Returns the single-float corresponding to a given bit represention.
|
int |
intValue()
Return the int value of this Number.
|
boolean |
isInfinite() |
static boolean |
isInfinite(float v) |
boolean |
isNaN() |
static boolean |
isNaN(float val) |
long |
longValue()
Return the long value of this Number.
|
static float |
parseFloat(String s)
Converts a String value into a float
|
short |
shortValue()
Return the short value of this Number.
|
String |
toString() |
static String |
toString(float f)
Convert a float to a String
|
static Float |
valueOf(float f) |
static Float |
valueOf(String s) |
public static final int MAX_EXPONENT
public static final float MAX_VALUE
public static final int MIN_EXPONENT
public static final float MIN_NORMAL
public static final float MIN_VALUE
public static final float NaN
public static final float NEGATIVE_INFINITY
public static final float POSITIVE_INFINITY
public static final int SIZE
public static final Class<?> TYPE
public Float(double value)
public Float(float value)
value - - the value to be represented by the Float.public Float(String s)
public byte byteValue()
Numberpublic static int compare(float a,
float b)
public int compareTo(Float other)
ComparablecompareTo in interface Comparable<Float>other - the object to compare withpublic double doubleValue()
NumberdoubleValue in class Numberpublic static int floatToIntBits(float value)
floatToRawIntBits this
method does collapse all NaN values into a standard single value. This
value is 0x7fc00000.value - a floating-point number.public static int floatToRawIntBits(float value)
0x80000000) represents the sign of the floating-point
number.
0x7f800000) represent the exponent.
0x007fffff) represent the significand (sometimes called
the mantissa) of the floating-point number.
0x7f800000.
0xff800000.
If the argument is NaN, the result is the integer representing the actual NaN value.
intBitsToFloat(int) method, will produce a floating-point
value equal to the argument to floatToRawIntBits.value - a floating-point number.public float floatValue()
floatValue in class Numberpublic static float intBitsToFloat(int value)
If the argument is 0x7f800000, the result is positive
infinity.
If the argument is 0xff800000, the result is negative
infinity.
If the argument is any value in the range 0x7f800001
through 0x7fffffff or in the range
0xff800001 through 0xffffffff, the result is
NaN. All IEEE 754 NaN values of type float are, in effect,
lumped together by the Java programming language into a single
float value called NaN. Distinct values of NaN are only
accessible by use of the Float.floatToRawIntBits method.
In all other cases, let s, e, and m be three values that can be computed from the argument:
int s = ((bits >> 31) == 0) ? 1 : -1;
int e = ((bits >> 23) & 0xff);
int m = (e == 0) ?
(bits & 0x7fffff) << 1 :
(bits & 0x7fffff) | 0x800000;
Then the floating-point result equals the value of the mathematical
expression s·m·2e-150.value - an integer.public int intValue()
Numberpublic boolean isInfinite()
public static boolean isInfinite(float v)
public boolean isNaN()
public static boolean isNaN(float val)
public long longValue()
Numberpublic static float parseFloat(String s) throws NumberFormatException
s - String representation of float. Must only contain numbers and an optional decimal, and optional - sign at front.NumberFormatExceptionpublic short shortValue()
NumbershortValue in class Numberpublic static String toString(float f)
f - the float to be convertedpublic static Float valueOf(float f)