java.lang
public
final
class
java.lang.Float
Float is the wrapper for the primitive type float.
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 |
TYPE |
The java.lang.Class that represents this class. |
|
|
Public Constructors
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
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
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. |
Public Methods
public
byte
byteValue()
Answers 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()
public
double
doubleValue()
Answers 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 answers 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
public
static
int
floatToIntBits(float value)
Answers the binary representation of the argument, as an int.
Parameters
| value
| The float value to convert |
public
static
int
floatToRawIntBits(float value)
Answers the binary representation of the argument, as an int.
Parameters
| value
| The float value to convert |
public
float
floatValue()
Answers the receiver's value as a float.
public
int
hashCode()
Answers 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.
public
static
float
intBitsToFloat(int bits)
Answers 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()
Answers the int value which the receiver represents
Returns
- int the value of the receiver.
public
static
boolean
isInfinite(float f)
Answers 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()
Answers 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)
Answers 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()
Answers 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()
Answers the long value which the receiver represents
Returns
- long the value of the receiver.
public
static
float
parseFloat(String string)
Answers 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
public
short
shortValue()
Answers 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.
Returns
- The hexadecimal string representation of
f.
public
static
String
toString(float f)
Answers a string containing a printable representation of the argument.
Returns
- a printable representation of the argument.
public
String
toString()
Answers 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.
public
static
Float
valueOf(String string)
Answers 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