Java Float类floatToIntBits()方法与示例
Float類floatToIntBits()方法 (Float class floatToIntBits() method)
floatToIntBits() method is available in java.lang package.
floatToIntBits()方法在java.lang包中可用。
floatToIntBits() method follows IEEE 754 floating-point standards and according to standards, it returns the bits representation that denotes floating-point value.
floatToIntBits()方法遵循IEEE 754浮點標(biāo)準(zhǔn),并且根據(jù)標(biāo)準(zhǔn),它返回表示浮點值的位表示形式。
floatToIntBits() method is a static method, it is accessible with the class name too and if we try to access the method with the class object then also we will not get an error.
floatToIntBits()方法是一個靜態(tài)方法,也可以使用類名進行訪問,如果嘗試使用類對象訪問該方法,那么也不會收到錯誤。
floatToIntBits() method does not throw an exception at the time of representing bits.
floatToIntBits()方法在表示位時不會引發(fā)異常。
Syntax:
句法:
public static int floatToIntBits(float f);Parameter(s):
參數(shù):
float f – represents the single precision floating point value.
float f –表示單精度浮點值。
Return value:
返回值:
The return type of this method is float, it returns the bits that represent the single precision floating-point value.
此方法的返回類型為float ,它返回表示單個精度浮點值的位。
If we pass "positive infinity", it returns the value "0x7f800000".
如果我們傳遞“ positive infinity” ,它將返回值“ 0x7f800000” 。
If we pass "negative infinity", it returns the value "0xff800000".
如果我們傳遞“負(fù)無窮大” ,它將返回值“ 0xff800000” 。
If we pass "NaN", it returns the value "0x7fc00000".
如果我們傳遞“ NaN” ,它將返回值“ 0x7fc00000” 。
Example:
例:
// Java program to demonstrate the example // of floatToIntBits (float value) // method of Float classpublic class FloatToIntBitsOfFloatClass {public static void main(String[] args) {// Variables initializationfloat value1 = 18.20f;float value2 = 19.20f;// Display value1,value2 valuesSystem.out.println("value1: " + value1);System.out.println("value2: " + value2);// It returns the bits denoted by the single // precision floating-point argument by calling // Float.floatToIntBits(value1)int result1 = Float.floatToIntBits(value1);// It returns the bits denoted by the single // precision floating-point argument by calling // Float.floatToIntBits(value2)int result2 = Float.floatToIntBits(value2);// Display result1,result2 valuesSystem.out.println("Float.floatToIntBits(value1): " + result1);System.out.println("Float.floatToIntBits(value2): " + result2);} }Output
輸出量
value1: 18.2 value2: 19.2 Float.floatToIntBits(value1): 1100061082 Float.floatToIntBits(value2): 1100585370翻譯自: https://www.includehelp.com/java/float-class-floattointbits-method-with-example.aspx
總結(jié)
以上是生活随笔為你收集整理的Java Float类floatToIntBits()方法与示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 极米Z5投影效果如果,多大的屏幕比较合适
- 下一篇: Java ByteArrayInputS