Public Member Functions | |
Float (jfloat _value=0) | |
Constructs a newly allocated Float object that represents the primitive float argument. | |
operator jfloat & () | |
virtual jboolean | isNaN () const |
Returns true if this Float value is Not-a-Number (NaN). | |
virtual jboolean | isInfinite () const |
Returns true if this Float value is infinitely large in magnitude. | |
virtual String | toString () const |
Returns a String representation of this Float object. | |
virtual jbyte | byteValue () const |
Returns the value of this Float as a byte. | |
virtual jshort | shortValue () const |
Returns the value of this Float as a short. | |
virtual jint | intValue () const |
Returns the value of this Float as an int. | |
virtual jlong | longValue () const |
Returns the value of this Float as a long . | |
virtual jfloat | floatValue () const |
Returns the value of this Float as a float . | |
virtual jdouble | doubleValue () const |
Returns the value of this Float as a double . | |
virtual jboolean | equals (const Object &src) const |
Compares this object against some other object. | |
virtual jint | hashCode () const |
Returns a hashcode for this Float object. | |
virtual jint | compareTo (const Object &src) const |
Compares this Float to another Object. | |
Static Public Member Functions | |
static jint | floatToIntBits (jfloat value) |
Returns the bit represention of a single-float value. | |
static jfloat | intBitsToFloat (jint bits) |
Returns the single-float corresponding to a given bit represention. | |
static jboolean | isNaN (jfloat v) |
Returns true if the specified number is the special Not-a-Number (NaN) value. | |
static jboolean | isInfinite (jfloat v) |
Returns true if the specified number is infinitely large in magnitude. | |
static String | toString (jfloat f) |
Returns a String representation for the specified float value. | |
static const Float | valueOf (const String &s) |
Returns the floating point value represented by the specified String. | |
static jfloat | parseFloat (const String &s) |
Returns a new float initialized to the value represented by the specified String , as performed by the valueOf method of class Double . | |
Static Public Attributes | |
static const jfloat | POSITIVE_INFINITY |
The positive infinity of type float . | |
static const jfloat | NEGATIVE_INFINITY |
The negative infinity of type float . | |
static const jfloat | NaN |
The Not-a-Number (NaN) value of type float . | |
static const jfloat | MIN_VALUE |
The smallest positive value of type float . | |
static const jfloat | MAX_VALUE |
The largest positive value of type float . |
java::lang::Float::Float | ( | jfloat | _value = 0 |
) |
Returns the bit represention of a single-float value.
The result is a representation of the floating-point argument according to the IEEE 754 floating-point "single precision" bit layout.
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
. 0x7fc00000
. floatToIntBits
.
value | a floating-point number. |
Returns the single-float corresponding to a given bit represention.
The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "single precision" bit layout.
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: <blockquote>
int s = ((bits >> 31) == 0) ? 1 : -1; int e = ((bits >> 23) & 0xff); int m = (e == 0) ? (bits & 0x7fffff) << 1 : (bits & 0x7fffff) | 0x800000;</blockquote> Then the floating-point result equals the value of the mathematical expression s·m·2^{e-150}.
bits | an integer. |
Returns true if the specified number is the special Not-a-Number (NaN) value.
v | the value to be tested. |
true
if the argument is NaN; false
otherwise. Returns true if the specified number is infinitely large in magnitude.
v | the value to be tested. |
true
if the argument is positive infinity or negative infinity; false
otherwise. Returns a String representation for the specified float value.
The argument is converted to a readable string format as follows. All characters and characters in strings mentioned below are ASCII characters.
"NaN"
. '-'
(''
); if the sign is positive, no sign character appears in the result. As for the magnitude m: "Infinity"
; thus, positive infinity produces the result "Infinity"
and negative infinity produces the result "-Infinity"
. "0.0"
; thus, negative zero produces the result "-0.0"
and positive zero produces the result "0.0"
. '.'
(
), followed by one or more decimal digits representing the fractional part of m. 0
.^{ }
f | the float to be converted. |
Returns the floating point value represented by the specified String.
The string s
is interpreted as the representation of a floating-point value and a Float
object representing that value is created and returned.
If s
is null
, then a NullPointerException
is thrown.
Leading and trailing whitespace characters in s are ignored. The rest of s
should constitute a FloatValue as described by the lexical syntax rules: <blockquote>
FloatValue:
Sign_{opt} FloatingPointLiteral</blockquote> where Sign, FloatingPointLiteral are as defined in ?.10.2 of the Java Language Specification. If it does not have the form of a FloatValue, then a
NumberFormatException
is thrown. Otherwise, it is regarded as representing an exact decimal value in the usual "computerized scientific notation"; this exact decimal value is then conceptually converted to an "infinitely precise" binary value that is then rounded to type float by the usual round-to-nearest rule of IEEE 754 floating-point arithmetic.
s | the string to be parsed. |
NumberFormatException | if the string does not contain a parsable number. |
Returns a new float initialized to the value represented by the specified String
, as performed by the valueOf
method of class Double
.
s | the string to be parsed. |
NumberFormatException | if the string does not contain a parsable float. |
java::lang::Float::operator jfloat & | ( | ) |
virtual jboolean java::lang::Float::isNaN | ( | ) | const [virtual] |
Returns true if this Float
value is Not-a-Number (NaN).
true
if the value represented by this object is NaN; false
otherwise. virtual jboolean java::lang::Float::isInfinite | ( | ) | const [virtual] |
Returns true if this Float value is infinitely large in magnitude.
true
if the value represented by this object is positive infinity or negative infinity; false
otherwise. virtual String java::lang::Float::toString | ( | ) | const [virtual] |
Returns a String representation of this Float object.
The primitive float
value represented by this object is converted to a String
exactly as if by the method toString
of one argument.
String
representation of this object. Reimplemented from java::lang::Object.
virtual jbyte java::lang::Float::byteValue | ( | ) | const [virtual] |
virtual jshort java::lang::Float::shortValue | ( | ) | const [virtual] |
virtual jint java::lang::Float::intValue | ( | ) | const [virtual] |
Returns the value of this Float as an int.
int
value represented by this object. Implements java::lang::Number.
virtual jlong java::lang::Float::longValue | ( | ) | const [virtual] |
Returns the value of this Float as a long
.
byte
value represented by this object that is converted to type long
and the result of the conversion is returned. Implements java::lang::Number.
virtual jfloat java::lang::Float::floatValue | ( | ) | const [virtual] |
Returns the value of this Float as a float
.
byte
value represented by this object is converted to type float
and the result of the conversion is returned. Implements java::lang::Number.
virtual jdouble java::lang::Float::doubleValue | ( | ) | const [virtual] |
Returns the value of this Float as a double
.
byte
value represented by this object is converted to type double
and the result of the conversion is returned. Implements java::lang::Number.
Compares this object against some other object.
The result is true
if and only if the argument is not null
and is a Float
object that represents a float
that has the identical bit pattern to the bit pattern of the float
represented by this object. For this purpose, two float values are considered to be the same if and only if the method floatToIntBits(float) returns the same 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 <blockquote>
f1.floatValue() == f2.floatValue()</blockquote>
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
.
obj | the object to be compared |
true
if the objects are the same; false
otherwise. Reimplemented from java::lang::Object.
virtual jint java::lang::Float::hashCode | ( | ) | const [virtual] |
Returns a hashcode for this Float
object.
The result is the integer bit representation, exactly as produced by the method floatToIntBits(float), of the primitive float value represented by this Float
object.
Reimplemented from java::lang::Object.
Compares this Float to another Object.
If the Object is a Float, this function behaves like compareTo(Float)
. Otherwise, it throws a ClassCastException
(as Floats are comparable only to other Floats).
o | the Object to be compared. |
0
if the argument is a Float numerically equal to this Float; a value less than 0
if the argument is a Float numerically greater than this Float; and a value greater than 0
if the argument is a Float numerically less than this Float. <code>ClassCastException</code> | if the argument is not a Float . |
Reimplemented from java::lang::Comparable.
const jfloat java::lang::Float::POSITIVE_INFINITY [static] |
The positive infinity of type float
.
It is equal to the value returned by Float.intBitsToFloat(0x7f800000)
.
const jfloat java::lang::Float::NEGATIVE_INFINITY [static] |
The negative infinity of type float
.
It is equal to the value returned by Float.intBitsToFloat(0xff800000)
.
const jfloat java::lang::Float::NaN [static] |
The Not-a-Number (NaN) value of type float
.
It is equal to the value returned by Float.intBitsToFloat(0x7fc00000)
.
const jfloat java::lang::Float::MIN_VALUE [static] |
The smallest positive value of type float
.
It is equal to the value returned by Float.intBitsToFloat(0x1)
.
const jfloat java::lang::Float::MAX_VALUE [static] |
The largest positive value of type float
.
It is equal to the value returned by Float.intBitsToFloat(0x7f7fffff)
.