Android
java.lang
public final class

java.lang.Float

java.lang.Object
java.lang.Number Serializable
java.lang.Float Comparable<T>

Float is the wrapper for the primitive type float.

See Also

Summary

Constants

      Value  
float  MAX_VALUE 

Constant for the maximum float value, (2 - 2-23) * 2127

3.4028235E38 
float  MIN_VALUE 

Constant for the minimum float value, 2-149

1.4E-45 
float  NEGATIVE_INFINITY 

Constant for the Negative Infinity value of the float type. 

-Infinity 
float  NaN 

Constant for the Not-a-Number (NaN) value of the float type. 

NaN 
float  POSITIVE_INFINITY 

Constant for the Positive Infinity value of the float type. 

Infinity 
int  SIZE 

Constant for the number of bits to represent a float in two's compliment form. 

32  0x00000020 
Class<Float TYPE  The java.lang.Class that represents this class.     

Public Constructors

            Float(float value)
Constructs a new instance of the receiver which represents the float valued argument.
            Float(double value)
Constructs a new instance of the receiver which represents the double valued argument.
            Float(String string)
Constructs a new instance of this class given a string.

Public Methods

          byte  byteValue()
Returns the byte value which the receiver represents
      static    int  compare(float float1, float float2)
Compares the two floats.
          int  compareTo(Float object)
Compares the receiver with the Float parameter.
          double  doubleValue()
Returns the double value which the receiver represents
          boolean  equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
      static    int  floatToIntBits(float value)
Returns the binary representation of the argument, as an int.
      static    int  floatToRawIntBits(float value)
Returns the binary representation of the argument, as an int.
          float  floatValue()
Returns the receiver's value as a float.
          int  hashCode()
Returns an integer hash code for the receiver.
      static    float  intBitsToFloat(int bits)
Returns a float built from the binary representation given in the argument.
          int  intValue()
Returns the int value which the receiver represents
      static    boolean  isInfinite(float f)
Returns true if the argument represents an infinite quantity, and false otherwise.
          boolean  isInfinite()
Returns true if the receiver represents an infinite quantity, and false otherwise.
      static    boolean  isNaN(float f)
Returns true if the argument does not represent a valid float quantity.
          boolean  isNaN()
Returns true if the receiver does not represent a valid float quantity.
          long  longValue()
Returns the long value which the receiver represents
      static    float  parseFloat(String string)
Returns the float which matches the passed in string.
          short  shortValue()
Returns the short value which the receiver represents
      static    String  toHexString(float f)

Converts a float into a hexadecimal string representation.

      static    String  toString(float f)
Returns a string containing a printable representation of the argument.
          String  toString()
Returns a string containing a concise, human-readable description of the receiver.
      static    Float  valueOf(float f)

Returns a Float instance for the float value passed.

      static    Float  valueOf(String string)
Returns the float which matches the passed in string.
Methods inherited from class java.lang.Number
Methods inherited from class java.lang.Object
Methods inherited from interface java.lang.Comparable

Details

Constants

public static final float MAX_VALUE

Constant for the maximum float value, (2 - 2-23) * 2127.

Constant Value: 3.4028235E38

public static final float MIN_VALUE

Constant for the minimum float value, 2-149.

Constant Value: 1.4E-45

public static final float NEGATIVE_INFINITY

Constant for the Negative Infinity value of the float type.

Constant Value: -Infinity

public static final float NaN

Constant for the Not-a-Number (NaN) value of the float type.

Constant Value: NaN

public static final float POSITIVE_INFINITY

Constant for the Positive Infinity value of the float type.

Constant Value: Infinity

public static final int SIZE

Constant for the number of bits to represent a float in two's compliment form.

Constant Value: 32 (0x00000020)

public static final Class<Float> TYPE

The java.lang.Class that represents this class.

Public Constructors

public Float(float value)

Constructs a new instance of the receiver which represents the float valued argument.

Parameters

value the float to store in the new instance.

public Float(double value)

Constructs a new instance of the receiver which represents the double valued argument.

Parameters

value the double to store in the new instance.

public Float(String string)

Constructs a new instance of this class given a string.

Parameters

string a string representation of a float quantity.

Throws

NumberFormatException if the argument could not be parsed as a float quantity.

Public Methods

public byte byteValue()

Returns the byte value which the receiver represents

Returns

  • byte the value of the receiver.

public static int compare(float float1, float float2)

Compares the two floats. NaN is equal to NaN, and is greater than other float values. 0f is greater than -0f.

Parameters

float1 the first value to compare
float2 the second value to compare

Returns

  • Returns greater than zero when float1 is greater than float2, zero when float1 equals float2, and less than zero when float1 is less than float2

public int compareTo(Float object)

Compares the receiver with the Float parameter. NaN is equal to NaN, and is greater than other float values. 0f is greater than -0f.

Parameters

object the Float to compare to the receiver

Returns

  • Returns greater than zero when this.floatValue() is greater than object.floatValue(), zero when this.floatValue() equals object.floatValue(), and less than zero when this.floatValue() is less than object.floatValue()

Throws

NullPointerException if object is null.

public double doubleValue()

Returns the double value which the receiver represents

Returns

  • double the value of the receiver.

public boolean equals(Object object)

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison. For Floats, the check verifies that the receiver's value's bit pattern matches the bit pattern of the argument, which must also be a Float.

Parameters

object the object to compare with this object

Returns

  • true if the object is the same as this object false if it is different from this object

See Also

public static int floatToIntBits(float value)

Returns the binary representation of the argument, as an int.

Parameters

value The float value to convert

Returns

  • the bits of the float.

public static int floatToRawIntBits(float value)

Returns the binary representation of the argument, as an int.

Parameters

value The float value to convert

Returns

  • the bits of the float.

public float floatValue()

Returns the receiver's value as a float.

Returns

  • the receiver's value

public int hashCode()

Returns an integer hash code for the receiver. Any two objects which answer true when passed to equals must answer the same value for this method.

Returns

  • the receiver's hash

See Also

public static float intBitsToFloat(int bits)

Returns a float built from the binary representation given in the argument.

Parameters

bits the bits of the float

Returns

  • the float which matches the bits

public int intValue()

Returns the int value which the receiver represents

Returns

  • int the value of the receiver.

public static boolean isInfinite(float f)

Returns true if the argument represents an infinite quantity, and false otherwise.

Parameters

f value to check for infinitness.

Returns

  • true if the argument is positive or negative infinity false if it is not an infinite value

public boolean isInfinite()

Returns true if the receiver represents an infinite quantity, and false otherwise.

Returns

  • true if the argument is positive or negative infinity false if it is not an infinite value

public static boolean isNaN(float f)

Returns true if the argument does not represent a valid float quantity.

Parameters

f value to check for numberness.

Returns

  • true if the argument is Not A Number false if it is a (potentially infinite) float number

public boolean isNaN()

Returns true if the receiver does not represent a valid float quantity.

Returns

  • true if the argument is Not A Number false if it is a (potentially infinite) float number

public long longValue()

Returns the long value which the receiver represents

Returns

  • long the value of the receiver.

public static float parseFloat(String string)

Returns the float which matches the passed in string. NumberFormatException is thrown if the string does not represent a valid float.

Parameters

string the value to convert

Returns

  • a float which would print as the argument

See Also

public short shortValue()

Returns the short value which the receiver represents

Returns

  • short the value of the receiver.

public static String toHexString(float f)

Converts a float into a hexadecimal string representation.

Parameters

f The float to convert.

Returns

  • The hexadecimal string representation of f.

public static String toString(float f)

Returns a string containing a printable representation of the argument.

Parameters

f the float to print

Returns

  • a printable representation of the argument.

public String toString()

Returns a string containing a concise, human-readable description of the receiver.

Returns

  • a printable representation for the receiver.

public static Float valueOf(float f)

Returns a Float instance for the float value passed. This method is preferred over the constructor, as this method may maintain a cache of instances.

Parameters

f The float value.

Returns

  • A Float instance.

public static Float valueOf(String string)

Returns the float which matches the passed in string. NumberFormatException is thrown if the string does not represent a valid float.

Parameters

string the value to convert

Returns

  • a float which would print as the argument
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48