java.lang.Object | ||
↳ | java.lang.Number | |
↳ | java.lang.Float |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | MAX_EXPONENT | Maximum base-2 exponent that a finite value of the float type may have. |
|||||||||
float | MAX_VALUE | Constant for the maximum float value, (2 - 2-23) * 2127. |
|||||||||
int | MIN_EXPONENT | Minimum base-2 exponent that a normal value of the float type may have. |
|||||||||
float | MIN_NORMAL | Constant for the smallest positive normal value of the float type. |
|||||||||
float | MIN_VALUE | Constant for the minimum float value, 2-149. |
|||||||||
float | NEGATIVE_INFINITY | Constant for the negative infinity value of the float type. |
|||||||||
float | NaN | Constant for the Not-a-Number (NaN) value of the float type. |
|||||||||
float | POSITIVE_INFINITY | Constant for the positive infinity value of the float type. |
|||||||||
int | SIZE | Constant for the number of bits needed to represent a float in
two's complement form. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
TYPE | The Class object that represents the primitive type float . |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new
Float with the specified primitive float value. | |||||||||||
Constructs a new
Float with the specified primitive double value. | |||||||||||
Constructs a new
Float from the specified string. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns this object's value as a byte.
| |||||||||||
Compares the two specified float values.
| |||||||||||
Compares this object to the specified float object to determine their
relative order.
| |||||||||||
Returns this object's value as a double.
| |||||||||||
Tests this double for equality with
object . | |||||||||||
Returns an integer corresponding to the bits of the given
IEEE 754 single precision
float
value . | |||||||||||
Returns an integer corresponding to the bits of the given
IEEE 754 single precision
float
value . | |||||||||||
Gets the primitive value of this float.
| |||||||||||
Returns an integer hash code for this object.
| |||||||||||
Returns the IEEE 754
single precision float corresponding to the given
bits . | |||||||||||
Returns this object's value as an int.
| |||||||||||
Indicates whether the specified float represents an infinite value.
| |||||||||||
Indicates whether this object represents an infinite value.
| |||||||||||
Indicates whether this object is a Not-a-Number (NaN) value.
| |||||||||||
Indicates whether the specified float is a Not-a-Number (NaN)
value.
| |||||||||||
Returns this object's value as a long.
| |||||||||||
Parses the specified string as a float value.
| |||||||||||
Returns this object's value as a short.
| |||||||||||
Converts the specified float into its hexadecimal string representation.
| |||||||||||
Returns a string containing a concise, human-readable description of this
object.
| |||||||||||
Returns a string containing a concise, human-readable description of the
specified float value.
| |||||||||||
Parses the specified string as a float value.
| |||||||||||
Returns a
Float instance for the specified float value. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Number
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Comparable
|
Maximum base-2 exponent that a finite value of the float
type may have.
Equal to Math.getExponent(Float.MAX_VALUE)
.
Constant for the maximum float
value, (2 - 2-23) * 2127.
Minimum base-2 exponent that a normal value of the float
type may have.
Equal to Math.getExponent(Float.MIN_NORMAL)
.
Constant for the smallest positive normal value of the float
type.
Constant for the minimum float
value, 2-149.
Constant for the negative infinity value of the float
type.
Constant for the Not-a-Number (NaN) value of the float
type.
Constant for the positive infinity value of the float
type.
Constant for the number of bits needed to represent a float
in
two's complement form.
The Class
object that represents the primitive type float
.
Constructs a new Float
with the specified primitive float value.
value | the primitive float value to store in the new instance. |
---|
Constructs a new Float
with the specified primitive double value.
value | the primitive double value to store in the new instance. |
---|
Constructs a new Float
from the specified string.
string | the string representation of a float value. |
---|
NumberFormatException | if string can not be parsed as a float value. |
---|
Returns this object's value as a byte. Might involve rounding and/or truncating the value, so it fits into a byte.
Compares the two specified float values. There are two special cases:
Float.NaN
is equal to Float.NaN
and it is greater
than any other float value, including Float.POSITIVE_INFINITY
;float1 | the first value to compare. |
---|---|
float2 | the second value to compare. |
float1
is less than float2
;
0 if float1
and float2
are equal; a positive
value if float1
is greater than float2
.Compares this object to the specified float object to determine their relative order. There are two special cases:
Float.NaN
is equal to Float.NaN
and it is greater
than any other float value, including Float.POSITIVE_INFINITY
;object | the float object to compare this object to. |
---|
object
; 0 if the value of this float and the
value of object
are equal; a positive value if the value
of this float is greater than the value of object
.Returns this object's value as a double. Might involve rounding.
Tests this double for equality with object
.
To be equal, object
must be an instance of Float
and
floatToIntBits
must give the same value for both objects.
Note that, unlike ==
, -0.0
and +0.0
compare
unequal, and NaN
s compare equal by this method.
object | the object to compare this float with. |
---|
true
if the specified object is equal to this
Float
; false
otherwise.
Returns an integer corresponding to the bits of the given
IEEE 754 single precision
float value
. All Not-a-Number (NaN) values are converted to a single NaN
representation (0x7fc00000
) (compare to floatToRawIntBits(float)
).
Returns an integer corresponding to the bits of the given
IEEE 754 single precision
float value
. Not-a-Number (NaN) values are preserved (compare
to floatToIntBits(float)
).
Gets the primitive value of this float.
Returns an integer hash code for this object. By contract, any two
objects for which equals(Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
Returns the IEEE 754
single precision float corresponding to the given bits
.
Returns this object's value as an int. Might involve rounding and/or truncating the value, so it fits into an int.
Indicates whether the specified float represents an infinite value.
f | the float to check. |
---|
true
if the value of f
is positive or negative
infinity; false
otherwise.
Indicates whether this object represents an infinite value.
true
if the value of this float is positive or negative
infinity; false
otherwise.
Indicates whether this object is a Not-a-Number (NaN) value.
true
if this float is Not-a-Number;
false
if it is a (potentially infinite) float number.
Indicates whether the specified float is a Not-a-Number (NaN) value.
f | the float value to check. |
---|
true
if f
is Not-a-Number;
false
if it is a (potentially infinite) float number.
Returns this object's value as a long. Might involve rounding and/or truncating the value, so it fits into a long.
Parses the specified string as a float value.
string | the string representation of a float value. |
---|
string
.NumberFormatException | if string can not be parsed as a float value. |
---|
Returns this object's value as a short. Might involve rounding and/or truncating the value, so it fits into a short.
Converts the specified float into its hexadecimal string representation.
f | the float to convert. |
---|
f
.Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString
method
if you intend implementing your own toString
method.
Returns a string containing a concise, human-readable description of the specified float value.
f | the float to convert to a string. |
---|
f
.
Parses the specified string as a float value.
string | the string representation of a float value. |
---|
Float
instance containing the float value represented
by string
.NumberFormatException | if string can not be parsed as a float value. |
---|
Returns a Float
instance for the specified float value.
f | the float value to store in the instance. |
---|
Float
instance containing f
.