📜  Java.lang.Float类

📅  最后修改于: 2020-11-15 03:00:39             🧑  作者: Mango


介绍

java.lang.Float类将原始类型float的值包装在对象中。 Float类型的对象包含一个类型为float的字段。

类声明

以下是java.lang.Float类的声明-

public final class Float
   extends Number
      implements Comparable

领域

以下是java.lang.Float类的字段-

  • static int MAX_EXPONENT-这是有限浮点变量可能具有的最大指数。

  • 静态浮动MAX_VALUE -这是一个常量保持类型浮体的最大正的有限值,(2-2- 23)·2 127。

  • static int MIN_EXPONENT-这是标准化的float变量可能具有的最小指数。

  • 静态浮动MIN_NORMAL -这是保持型浮子,2- 126的最小正正常值的常数。

  • 静态浮点数MIN_VALUE-这是一个常量,它持有float最小的正非零值2-149

  • 静态浮点NaN-这是一个常量,其中包含浮点类型的非数字(NaN)值。

  • 静态浮点数NEGATIVE_INFINITY-这是一个常量,用于保存float类型的负无穷大。

  • 静态浮点POSITIVE_INFINITY-这是一个常数,保持浮点类型的正无穷大。

  • static int SIZE-这是用于表示浮点值的位数。

  • 静态Class TYPE-这是表示基本类型float的Class实例。

类的构造函数

Sr.No. Constructor & Description
1

Float(double value)

This constructs a newly allocated Float object that represents the argument converted to type float.

2

Float(float value)

This constructs a newly allocated Float object that represents the primitive float argument.

3

Float(String s)

This constructs a newly allocated Float object that represents the floating-point value of type float represented by the string.

类方法

Sr.No. Method & Description
1 byte byteValue()

This method returns the value of this Float as a byte (by casting to a byte).

2 static int compare(float f1, float f2)

This method compares the two specified float values.

3 int compareTo(Float anotherFloat)

This method compares two Float objects numerically.

4 double doubleValue()

This method returns the double value of this Float object.

5 boolean equals(Object obj)

This method compares this object against the specified object.

6 static int floatToIntBits(float value)

This method returns a representation of the specified floating-point value according to the IEEE 754 floating-point “single format” bit layout.

7 static int floatToRawIntBits(float value)

This method 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.

8 float floatValue()

This method returns the float value of this Float object.

9 int hashCode()

This method returns a hash code for this Float object.

10 static float intBitsToFloat(int bits)

This method returns the float value corresponding to a given bit representation.

11 int intValue()

This method returns the value of this Float as an int (by casting to type int).

12 boolean isInfinite()

This method returns true if this Float value is infinitely large in magnitude, false otherwise.

13 static boolean isInfinite(float v)

This method returns true if the specified number is infinitely large in magnitude, false otherwise.

14 boolean isNaN()

This method returns true if this Float value is a Not-a-Number (NaN), false otherwise.

15 static boolean isNaN(float v)

This method returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

16 long longValue()

This method returns value of this Float as a long (by casting to type long).

17 static float parseFloat(String s)

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

18 short shortValue()

This method returns the value of this Float as a short (by casting to a short).

19 static String toHexString(float f)

This method returns a hexadecimal string representation of the float argument.

20 String toString()

This method returns a string representation of this Float object.

21 static String toString(float f)

This method returns a string representation of the float argument

22 static Float valueOf(float f)

This method returns a Float instance representing the specified float value.

23 static Float valueOf(String s)

This method returns a Float object holding the float value represented by the argument string s.

方法继承

此类从以下类继承方法-

  • java.lang.Object