Javatpoint Logo
Javatpoint Logo

Java Float class

The Float class wraps a primitive float type value in an object. Its object contains only a single field whose type is float.


Methods Description
byteValue() Returns the value of this float as a byte
compare() Compares the two specified float values
compareTo() Compares two float objects numerically
doubleValue() Returns a double value for this Float object
equals() Compares the object against the specified object
floatToIntBits() Returns a representation of floating-point value according to IEEE floating-point "single format " bit layout
floatToRawIntBits() Returns a representation of floating-point value according to IEEE floating-point "single format" bit layout preserving NaN values.
floatValue() Returns the float value of this Float object
hashCode() Returns a hash code for this Float object
intBitsToFloat() Returns the float value for the given bit representation
intValue() Returns an int value for this Float object
isFinite() Returns a Boolean value 'true', if the argument is a finite floating-point value
isInfinite() Returns a Boolean value 'true', if this float value or the specified number is infinitely large in magnitude
isNan() Returns a Boolean value 'true', if the specified number is NaN(Not a Nan) value.
longValue() Returns a long value for this float object
max() Returns the greatest of two float values and gives the same result as by calling Math.max
min() Returns the smallest of two float values
parseFloat() Returns a new float initialized to the value of the specified String
shortValue() Returns a short value for this Float object
sum() Adds the two float values together
toHexString() Returns a hexadecimal string representation of the float argument.
toString() Returns a string representation of the Float object
valueOf() Returns a Float instance representing the specified float or string value.

Example 1

Test it Now


Infinity value for isInfinite() method is : true
34.0 value for Finite() method : true
intValue() method will return : 34.0*Infinity = -34
Hash code value of 34.0 is : 1107820544

Example 2

Test it Now


1. Value = 4863.0
2. Concatenated String = 4863.02872.0
3. Hex String = 0x1.2ffp12
4. Sum of two numbers = 7735.0

Next TopicJava Float

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA