GeezerVison is showing docs.oracle.com — Float (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.lang
Class Float
-
-
Field Summary
Fields
| Modifier and Type |
Field |
Description |
static int |
BYTES |
The number of bytes used to represent a float value.
|
static int |
MAX_EXPONENT |
Maximum exponent a finite float variable may have.
|
static float |
MAX_VALUE |
A constant holding the largest positive finite value of type
float, (2-2-23)·2127.
|
static int |
MIN_EXPONENT |
Minimum exponent a normalized float variable may have.
|
static float |
MIN_NORMAL |
A constant holding the smallest positive normal value of type
float, 2-126.
|
static float |
MIN_VALUE |
A constant holding the smallest positive nonzero value of type
float, 2-149.
|
static float |
NaN |
A constant holding a Not-a-Number (NaN) value of type
float.
|
static float |
NEGATIVE_INFINITY |
A constant holding the negative infinity of type
float.
|
static float |
POSITIVE_INFINITY |
A constant holding the positive infinity of type
float.
|
static int |
SIZE |
The number of bits used to represent a float value.
|
static Class<Float> |
TYPE |
The Class instance representing the primitive type
float.
|
-
Constructor Summary
Constructors
| Constructor |
Description |
Float(double value) |
Constructs a newly allocated Float object that
represents the argument converted to type float.
|
Float(float value) |
Constructs a newly allocated Float object that
represents the primitive float argument.
|
Float(String s) |
Constructs a newly allocated Float object that
represents the floating-point value of type float
represented by the string.
|
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
| Modifier and Type |
Method |
Description |
byte |
byteValue() |
Returns the value of this Float as a byte after
a narrowing primitive conversion.
|
static int |
compare(float f1,
float f2) |
Compares the two specified float values.
|
int |
compareTo(Float anotherFloat) |
Compares two Float objects numerically.
|
double |
doubleValue() |
Returns the value of this Float as a double
after a widening primitive conversion.
|
boolean |
equals(Object obj) |
Compares this object against the specified object.
|
static int |
floatToIntBits(float value) |
Returns a representation of the specified floating-point value
according to the IEEE 754 floating-point "single format" bit
layout.
|
static int |
floatToRawIntBits(float value) |
Returns a representation of the specified floating-point value
according to the IEEE 754 floating-point "single format" bit
layout, preserving Not-a-Number (NaN) values.
|
float |
floatValue() |
Returns the float value of this Float object.
|
int |
hashCode() |
Returns a hash code for this Float object.
|
static int |
hashCode(float value) |
Returns a hash code for a float value; compatible with
Float.hashCode().
|
static float |
intBitsToFloat(int bits) |
Returns the float value corresponding to a given
bit representation.
|
int |
intValue() |
Returns the value of this Float as an int after
a narrowing primitive conversion.
|
static boolean |
isFinite(float f) |
Returns true if the argument is a finite floating-point
value; returns false otherwise (for NaN and infinity
arguments).
|
boolean |
isInfinite() |
Returns true if this Float value is
infinitely large in magnitude, false otherwise.
|
static boolean |
isInfinite(float v) |
Returns true if the specified number is infinitely
large in magnitude, false otherwise.
|
boolean |
isNaN() |
Returns true if this Float value is a
Not-a-Number (NaN), false otherwise.
|
static boolean |
isNaN(float v) |
Returns true if the specified number is a
Not-a-Number (NaN) value, false otherwise.
|
long |
longValue() |
Returns value of this Float as a long after a
narrowing primitive conversion.
|
static float |
max(float a,
float b) |
Returns the greater of two float values
as if by calling Math.max.
|
static float |
min(float a,
float b) |
Returns the smaller of two float values
as if by calling Math.min.
|
static float |
parseFloat(String s) |
Returns a new float initialized to the value
represented by the specified String, as performed
by the valueOf method of class Float.
|
short |
shortValue() |
Returns the value of this Float as a short
after a narrowing primitive conversion.
|
static float |
sum(float a,
float b) |
Adds two float values together as per the + operator.
|
static String |
toHexString(float f) |
Returns a hexadecimal string representation of the
float argument.
|
String |
toString() |
Returns a string representation of this Float object.
|
static String |
toString(float f) |
Returns a string representation of the float
argument.
|
static Float |
valueOf(float f) |
Returns a Float instance representing the specified
float value.
|
static Float |
valueOf(String s) |
Returns a Float object holding the
float value represented by the argument string
s.
|
-
-
Field Detail
-
MAX_VALUE
public static final float MAX_VALUE
A constant holding the largest positive finite value of type
float, (2-2-23)·2127.
It is equal to the hexadecimal floating-point literal
0x1.fffffeP+127f and also equal to
Float.intBitsToFloat(0x7f7fffff).
- See Also:
- Constant Field Values
-
MIN_NORMAL
public static final float MIN_NORMAL
A constant holding the smallest positive normal value of type
float, 2-126. It is equal to the
hexadecimal floating-point literal 0x1.0p-126f and also
equal to Float.intBitsToFloat(0x00800000).
- Since:
- 1.6
- See Also:
- Constant Field Values
-
MIN_VALUE
public static final float MIN_VALUE
A constant holding the smallest positive nonzero value of type
float, 2-149. It is equal to the
hexadecimal floating-point literal 0x0.000002P-126f
and also equal to Float.intBitsToFloat(0x1).
- See Also:
- Constant Field Values
-
Constructor Detail
-
Float
public Float(String s)
throws NumberFormatException
Constructs a newly allocated Float object that
represents the floating-point value of type float
represented by the string. The string is converted to a
float value as if by the valueOf method.
- Parameters:
s - a string to be converted to a Float.
- Throws:
NumberFormatException - if the string does not contain a
parsable number.
- See Also:
valueOf(java.lang.String)
-
Method Detail
-
parseFloat
public static float parseFloat(String s)
throws NumberFormatException
Returns a new float initialized to the value
represented by the specified String, as performed
by the valueOf method of class Float.
- Parameters:
s - the string to be parsed.
- Returns:
- the
float value represented by the string
argument.
- Throws:
NullPointerException - if the string is null
NumberFormatException - if the string does not contain a
parsable float.
- Since:
- 1.2
- See Also:
valueOf(String)
-
isNaN
public static boolean isNaN(float v)
Returns true if the specified number is a
Not-a-Number (NaN) value, false otherwise.
- Parameters:
v - the value to be tested.
- Returns:
true if the argument is NaN;
false otherwise.
-
isInfinite
public static boolean isInfinite(float v)
Returns true if the specified number is infinitely
large in magnitude, false otherwise.
- Parameters:
v - the value to be tested.
- Returns:
true if the argument is positive infinity or
negative infinity; false otherwise.
-
isInfinite
public boolean isInfinite()
Returns true if this Float value is
infinitely large in magnitude, false otherwise.
- Returns:
true if the value represented by this object is
positive infinity or negative infinity;
false otherwise.
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|