Float class Methods in Java

java.lang.Float

The Float class wraps a value of primitive type float in an object. An object of type Float contains a single field whose type is float. In addition, this class provides several methods for converting a float to a String and a String to the float, as well as other constants and methods useful when dealing with the float.

Some methods of Float class

Float.BYTESThe number of bytes is used to represent a float value (i.e. 4).


Float.compare(): It compares the two specified float values.


Float.floatToIntBits(): It returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout.


Float.floatToRawIntBits()It 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.hashCode()It returns a hash code for a float value.


Float.intBitsToFloat()It returns the float value corresponding to a given bit representation.


Float.isFinite(): It returns true if the argument is a finite floating-point value; returns false otherwise (for NaN and infinity arguments).


Float.isInfinite() It returns true if the specified number is infinitely large in magnitude, false otherwise.


Float.isNaN()It returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.


Float.max()It returns the greater of two float values.


Float.MAX_EXPONENTMaximum exponent a finite float variable may have.


Float.MAX_VALUEA constant holding the largest positive finite value of type float (i.e 3.4028235E38).


Float.min()It returns the smaller of two float values.


Float.MIN_EXPONENTMinimum exponent a normalized float variable may have (i.e. -126).


Float.MIN_NORMALA constant holding the smallest positive normal value of type float (i.e. 1.17549435E-38).


Float.NaNA constant holding a Not-a-Number (NaN) value of type float (i.e. NaN)


Float.NEGATIVE_INFINITYA constant holding the negative infinity of type float (i.e -Infinity).


Float.parseFloat()It returns a new float initialized to the value represented by the specified String, as performed by the valueOf method of class Float.


Float.POSITIVE_INFINITYA constant holding the positive infinity of type float (i.e. Infinity).


Float.SIZEThe number of bits used to represent a float value (i.e 32).


Float.sum()It adds two float values together as per the + operator.

Float.toHexString()It returns a hexadecimal string representation of the float argument.


Float.toString()It returns a string representation of the float argument.


Float.valueOf(float f)It returns a Float instance representing the specified float value.


Float.valueOf(String s)It returns a Float object holding the float value represented by the argument string s.



No comments:

Post a Comment