aicas logo Jamaica 3.4 release 8

java.lang
Class Float

java.lang.Object
  extended by java.lang.Number
      extended by java.lang.Float
All Implemented Interfaces:
Serializable, Comparable<Float>

public final class Float
extends Number
implements Comparable<Float>

Float provides a class for float values stored in objects.

See Also:
Serialized Form

Field Summary
static int MAX_EXPONENT
          The maximum value the exponent may have.
static float MAX_VALUE
          The largest value a float can hold.
static int MIN_EXPONENT
          The minimum value the exponent may have.
static float MIN_NORMAL
          The smallest positive value that can be represented by a normalized float.
static float MIN_VALUE
          The smalles value a float can hold.
static float NaN
          Numerical constant: NaN
static float NEGATIVE_INFINITY
          Numerical constant: -Infinity
static float POSITIVE_INFINITY
          Numerical constant: +Infinity
static int SIZE
          The size occupied by one double in bits.
static Class<Float> TYPE
          type for float.
 
Constructor Summary
Float(double value)
          Constructor to create an instance of Float with the given double value converted to float.
Float(float value)
          Constructor to create an instance of Float with the given float value.
Float(String s)
          Constructor to create an instance of Float with the value provided as a string.
 
Method Summary
 byte byteValue()
          byteValue returns the value of this as a byte.
static int compare(float v1, float v2)
          compare compares two float values
 int compareTo(Float o)
          compareTo compares this to another Float value.
 double doubleValue()
          doubleValue returns the value of this as a double.
 boolean equals(Object obj)
          equals tests if 2 double instances are equal.
static int floatToIntBits(float value)
          floatToIntBits returns the integer representation of a float value.
static int floatToRawIntBits(float value)
          floatToRawIntBits returns the raw integer representation of a float value.
 float floatValue()
          floatValue returns the value of this as a float.
 int hashCode()
          hashCode determines a hashCode for this Float instance.
static float intBitsToFloat(int bits)
          intBitsToFloat creates a float value with the given integer representation.
 int intValue()
          intValue returns the value of this as an int.
 boolean isInfinite()
          isInfinite checks if this instance represents Infinity or -Infinity.
static boolean isInfinite(float v)
          isInfinite checks if the float value is Infinity or -Infinity.
 boolean isNaN()
          isNaN checks if this instance represents a NaN
static boolean isNaN(float v)
          isNaN checks if the float value is a NaN.
 long longValue()
          longValue returns the value of this as a long.
static float parseFloat(String floatString)
          parseFloat parses a float value given as a string.
 short shortValue()
          shortValue returns the value of this as a short.
static String toHexString(float f)
          Convert this float value to a hex string of the form "0x0.123456p123".
 String toString()
          toString converts the value of this instance to a string just as toString(floatValue()).
static String toString(float v)
          toString converts a given float value to a string.
static Float valueOf(float f)
          valueOf returns a Float instance with the given value.
static Float valueOf(String s)
          valueOf creates an instance of Float with the value provided as a string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

POSITIVE_INFINITY

public static final float POSITIVE_INFINITY
Numerical constant: +Infinity

See Also:
Constant Field Values

NEGATIVE_INFINITY

public static final float NEGATIVE_INFINITY
Numerical constant: -Infinity

See Also:
Constant Field Values

NaN

public static final float NaN
Numerical constant: NaN

See Also:
Constant Field Values

MIN_VALUE

public static final float MIN_VALUE
The smalles value a float can hold.

See Also:
Constant Field Values

MAX_VALUE

public static final float MAX_VALUE
The largest value a float can hold.

See Also:
Constant Field Values

MIN_NORMAL

public static final float MIN_NORMAL
The smallest positive value that can be represented by a normalized float.

Since:
1.6
See Also:
Constant Field Values

MAX_EXPONENT

public static final int MAX_EXPONENT
The maximum value the exponent may have. NYI: 1.6 field: Check if value is correct.

Since:
1.6
See Also:
Constant Field Values

MIN_EXPONENT

public static final int MIN_EXPONENT
The minimum value the exponent may have. NYI: 1.6 field: Check if value is correct.

Since:
1.6
See Also:
Constant Field Values

SIZE

public static final int SIZE
The size occupied by one double in bits.

Since:
1.5
See Also:
Constant Field Values

TYPE

public static final Class<Float> TYPE
type for float.

Since:
1.1
Constructor Detail

Float

public Float(float value)
Constructor to create an instance of Float with the given float value.

Parameters:
value - the value for this instance.

Float

public Float(double value)
Constructor to create an instance of Float with the given double value converted to float.

Parameters:
value - the value for this instance.

Float

public Float(String s)
      throws NumberFormatException
Constructor to create an instance of Float with the value provided as a string.

Parameters:
s - the string representation of the value.
Throws:
NumberFormatException - if s could not be parsed as a float.
Method Detail

toString

public static String toString(float v)
toString converts a given float value to a string. Converts special values NaN, positive and negative Infinitiy to "NaN", "Infinity" and "-Infinity", respectively. All other values are represented in the form "#.###[E[-]##]".

Parameters:
v - the float value.
Returns:
the string representing the same value.

toHexString

public static String toHexString(float f)
Convert this float value to a hex string of the form "0x0.123456p123".

Parameters:
f - a float
Returns:
the hex string
Since:
1.5

valueOf

public static Float valueOf(String s)
                     throws NumberFormatException
valueOf creates an instance of Float with the value provided as a string.

Parameters:
s - the string representation of the value.
Returns:
an instance of Float that represents the given value.
Throws:
NumberFormatException - if s could not be parsed as a float.

valueOf

public static Float valueOf(float f)
valueOf returns a Float instance with the given value. A cache is used to speed up multiple allocations of the same Float instance.

Parameters:
f - the float value
Returns:
an instance with value equal to f.
Since:
1.5

parseFloat

public static float parseFloat(String floatString)
                        throws NumberFormatException
parseFloat parses a float value given as a string. The value may be of the form "[+|-]#{#}[.#{#}[E[+|-]#{#}]][D|F]".

Parameters:
floatString - the string represenation.
Returns:
the corresponding float value or +/-Infinity in case of an
         overflow.
 
Throws:
NumberFormatException
Since:
1.2

isNaN

public static boolean isNaN(float v)
isNaN checks if the float value is a NaN.

Parameters:
v - the float value.
Returns:
true iff v is NaN

isInfinite

public static boolean isInfinite(float v)
isInfinite checks if the float value is Infinity or -Infinity.

Parameters:
v - the float value
Returns:
true iff v is Infinity of -Infinity.

isNaN

public boolean isNaN()
isNaN checks if this instance represents a NaN

Returns:
true iff this is NaN

isInfinite

public boolean isInfinite()
isInfinite checks if this instance represents Infinity or -Infinity.

Returns:
true iff this is Infinity of -Infinity.

toString

public String toString()
toString converts the value of this instance to a string just as toString(floatValue()).

Overrides:
toString in class Object
Returns:
the string representing the same value as this.

byteValue

public byte byteValue()
byteValue returns the value of this as a byte.

Overrides:
byteValue in class Number
Returns:
the value converted to byte.
Since:
1.1

shortValue

public short shortValue()
shortValue returns the value of this as a short.

Overrides:
shortValue in class Number
Returns:
the value converted to short.
Since:
1.1

intValue

public int intValue()
intValue returns the value of this as an int.

Specified by:
intValue in class Number
Returns:
the value converted to int.

longValue

public long longValue()
longValue returns the value of this as a long.

Specified by:
longValue in class Number
Returns:
the value converted to long.

floatValue

public float floatValue()
floatValue returns the value of this as a float.

Specified by:
floatValue in class Number
Returns:
the value converted to float.

doubleValue

public double doubleValue()
doubleValue returns the value of this as a double.

Specified by:
doubleValue in class Number
Returns:
the value converted to double.

hashCode

public int hashCode()
hashCode determines a hashCode for this Float instance.

Overrides:
hashCode in class Object
Returns:
the hash code.

equals

public boolean equals(Object obj)
equals tests if 2 double instances are equal. Two instances are equal if their bit patterns (see floatToIntBits) are equal, i.e., this function does not returns the same value as a plain comparison "d1==d2" would.

Overrides:
equals in class Object
Parameters:
obj - the other double value
Returns:
true iff obj is an isntance of Float and floatToIntBits(value) ==
         floatToIntToLongBits(((Float) obj).floatValue()).
 

floatToIntBits

public static int floatToIntBits(float value)
floatToIntBits returns the integer representation of a float value.

Parameters:
value - the float value.
Returns:
the bits of the float value interpreted as an int.

floatToRawIntBits

public static int floatToRawIntBits(float value)
floatToRawIntBits returns the raw integer representation of a float value. The raw representation permits several integer representations for the same values: NaN and +/-Infinity.

Parameters:
value - the float value.
Returns:
the bits of the float value interpreted as an int.

intBitsToFloat

public static float intBitsToFloat(int bits)
intBitsToFloat creates a float value with the given integer representation.

Parameters:
bits - the integer representation.
Returns:
the float value.

compareTo

public int compareTo(Float o)
compareTo compares this to another Float value.

Specified by:
compareTo in interface Comparable<Float>
Parameters:
o - the other float
Returns:
-1 if this is smaller than, 0 if this is equal to, +1 if this is
         larger than o.
 
Since:
1.2

compare

public static int compare(float v1,
                          float v2)
compare compares two float values

Parameters:
v1 - the first float value
v2 - the second float value
Returns:
-1 if this is smaller than, 0 if this is equal to, +1 if this is
         larger than o.
 
Since:
1.4

aicas logo Jamaica 3.4 release 8

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2009 aicas GmbH. All Rights Reserved.