java::lang::Float Class Reference

Inheritance diagram for java::lang::Float:

Inheritance graph
java::lang::Numberjava::lang::Objectjava::lang::Interfacejava::lang::Comparable
[legend]
Collaboration diagram for java::lang::Float:

Collaboration graph
java::lang::Numberjava::lang::Objectjava::lang::Interfacejava::lang::Comparable
[legend]

List of all members.


Detailed Description

The Float class is the standard wrapper for byte values.

Author:
Nakul Saraiya

Yuh-Jye Chang

Version:
1.20, 02/02/00
See also:
java.lang.Number
Since:
JDK1.1

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.

Constructor & Destructor Documentation

java::lang::Float::Float ( jfloat  _value = 0  ) 

Constructs a newly allocated Float object that represents the primitive float argument.

Parameters:
value the value to be represented by the Float.


Member Function Documentation

static jint java::lang::Float::floatToIntBits ( jfloat  value  )  [static]

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.

In all cases, the result is an integer that, when given to the intBitsToFloat(int) method, will produce a floating-point value equal to the argument to floatToIntBits.

Parameters:
value a floating-point number.
Returns:
the bits that represent the floating-point number.

static jfloat java::lang::Float::intBitsToFloat ( jint  bits  )  [static]

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&#183;m&#183;2e-150.

Parameters:
bits an integer.
Returns:
the single-format floating-point value with the same bit pattern.

static jboolean java::lang::Float::isNaN ( jfloat  v  )  [static]

Returns true if the specified number is the special Not-a-Number (NaN) value.

Parameters:
v the value to be tested.
Returns:
true if the argument is NaN; false otherwise.

static jboolean java::lang::Float::isInfinite ( jfloat  v  )  [static]

Returns true if the specified number is infinitely large in magnitude.

Parameters:
v the value to be tested.
Returns:
true if the argument is positive infinity or negative infinity; false otherwise.

static String java::lang::Float::toString ( jfloat  f  )  [static]

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.

static const Float java::lang::Float::valueOf ( const String s  )  [static]

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:

          Signopt 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.

Parameters:
s the string to be parsed.
Returns:
a newly constructed Float initialized to the value represented by the String argument.
Exceptions:
NumberFormatException if the string does not contain a parsable number.

static jfloat java::lang::Float::parseFloat ( const String s  )  [static]

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.
Exceptions:
NumberFormatException if the string does not contain a parsable float.
See also:
java.lang.Double::valueOf(String)
Since:
1.2

java::lang::Float::operator jfloat & (  ) 

virtual jboolean java::lang::Float::isNaN (  )  const [virtual]

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

Returns:
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.

Returns:
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.

Returns:
a String representation of this object.
See also:
java.lang.Float::toString(float)

Reimplemented from java::lang::Object.

virtual jbyte java::lang::Float::byteValue (  )  const [virtual]

Returns the value of this Float as a byte.

Since:
JDK1.1

Reimplemented from java::lang::Number.

virtual jshort java::lang::Float::shortValue (  )  const [virtual]

Returns the value of this Float as a short.

Since:
JDK1.1

Reimplemented from java::lang::Number.

virtual jint java::lang::Float::intValue (  )  const [virtual]

Returns the value of this Float as an int.

Returns:
the 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.

Returns:
the 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.

Returns:
the 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.

Returns:
the byte value represented by this object is converted to type double and the result of the conversion is returned.

Implements java::lang::Number.

virtual jboolean java::lang::Float::equals ( const Object src  )  const [virtual]

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:

This definition allows hashtables to operate properly.

Parameters:
obj the object to be compared
Returns:
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.

Returns:
a hash code value for this object.

Reimplemented from java::lang::Object.

virtual jint java::lang::Float::compareTo ( const Object src  )  const [virtual]

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).

Parameters:
o the Object to be compared.
Returns:
the value 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.
Exceptions:
<code>ClassCastException</code> if the argument is not a Float.
See also:
java.lang.Comparable
Since:
1.2

Reimplemented from java::lang::Comparable.


Member Data Documentation

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).


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:37 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3