Float

Name

Float

Synopsis

Description

The Float class provides an object wrapper for a float value. This is useful when you need to treat a float value as an object. For example, there are a number of utility methods that take a reference to an Object as one of their arguments. You cannot specify a float value for one of these arguments, but you can provide a reference to a Float object that encapsulates the float value. Furthermore, as of JDK 1.1, the Float class is necessary to support the Reflection API and class literals.

In Java, float values are represented using the IEEE 754 format. The Float class provides constants for the three special values that are mandated by this format: POSITIVE_INFINITY, NEGATIVE_INFINITY, and NaN (not-a-number).

The Float class also provides some utility methods, such as methods for determining whether a floatx value is an infinity value or NaN, for converting float values to other primitive types, and for converting a float to a String and vice versa.

Class Summary

public final class java.lang.Float extends java.lang.Number {
 // Constants public static final float MIN_VALUE;
public static final float MAX_VALUE;
public static final float NaN;
public static final float NEGATIVE_INFINITY;
public static final float POSITIVE_INFINITY;
public final static Class TYPE; // New in 1.1 // Constructors public Float(double value);
public Float(float value);
public Float(String s); // Class Methods public static native int floatToIntBits(float value);
public static native float intBitsToFloat(int bits);
public static boolean isInfinite(float v);
public static boolean isNaN(float v);
public static String toString(float f);
public static Float valueOf(String s); // Instance Methods public byte byteValue(); // New in 1.1 public double doubleValue();
public boolean equals(Object obj);
public float floatValue();
public int hashCode();
public int intValue();
public boolean isInfinite();
public boolean isNaN();
public long longValue();
public short shortValue(); // New in 1.1 public String toString();
}

Constants

MAX_VALUE

public static final float MAX_VALUE = 3.40282346638528860e+38f

MIN_VALUE

public static final float MIN_VALUE = 1.40129846432481707e-45f

NaN

public static final float NaN = 0.0f / 0.0f

NEGATIVE_INFINITY

public static final float NEGATIVE_INFINITY = -1.0f / 0.0f

POSITIVE_INFINITY

public static final float POSITIVE_INFINITY = 1.0f / 0.0f

TYPE

public static final Class TYPE

Constructors

Float

public Float(double value)

public Float(float value)

public Float(String s) throws NumberFormatException

Class Methods

floatToIntBits

public static native int floatToIntBits(float value)

intBitsToFloat

public static native float intBitsToFloat(int bits)

isInfinite

public static boolean isInfinite(float v)

isNaN

public static boolean isNaN(float v)

toString

public static String toString(float f)

valueOf

public static Float valueOf(String s) throws NumberFormatException 

Instance Methods

byteValue

public byte byteValue()

doubleValue

public double doubleValue()

equals

public boolean equals(Object obj)

floatValue

public float floatValue()

hashCode

public int hashCode()

intValue

public int intValue()

isInfinite

public boolean isInfinite(float v)

isNaN

public boolean isNaN()

longValue

public long longValue()

shortValue

public short shortValue()

toString

public String toString()

Inherited Methods

Method Inherited From Method Inherited From
clone() Object finalize() Object
getClass() Object notify() Object
notifyAll() Object wait() Object
wait(long) Object wait(long, int) Object

See Also

Class; Double; Exceptions; Floating-point literals; Floating-point types; Number; String