Java Double类longBitsToDouble()方法与示例

Double类longBitsToDouble()方法 (Double class longBitsToDouble() method)

  • longBitsToDouble() method is available in java.lang package.

    longBitsToDouble()方法在java.lang包中可用。

  • longBitsToDouble() method is used to return the double value corresponding to the given long bit denotation followed by IEEE 754 double floating-point standards.

    longBitsToDouble()方法用于返回与给定的长位符号对应的双精度值,后跟IEEE 754双浮点标准。

  • longBitsToDouble() 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.

    longBitsToDouble()方法是一个静态方法,也可以使用类名进行访问,如果尝试使用类对象访问该方法,那么也不会出错。

  • longBitsToDouble() method does not throw an exception at the time of representing bits.

    longBitsToDouble()方法在表示位时不会引发异常。

Syntax:

句法:

    public static double longBitsToDouble(long bits_rep);

Parameter(s):

参数:

  • long bits_rep – represents the long integer value.

    long bits_rep –表示长整数值。

Return value:

返回值:

The return type of this method is double, it returns the bits that represent the long integer value.

此方法的返回类型为double ,它返回表示长整数值的位。

Note:

注意:

  • If we pass "0x7ff0000000000000L", it returns the value "positive infinity".

    如果我们传递“ 0x7ff0000000000000L” ,它将返回值“ positive infinity”

  • If we pass "0xfff0000000000000L", it returns the value "negative infinity".

    如果我们传递“ 0xfff0000000000000L” ,它将返回值“ negative infinity”

Example:

例:

// Java program to demonstrate the example 
// of longBitsToDouble(long bits_rep)
// method of Double class

public class LongBitsToDoubleOfDoubleClass {
     
    public static void main(String[] args) {
     
        // Variables initialization
        double d1 = 18.20;
        double d2 = 19.20;

        // Display value1,value2 values
        System.out.println("d1: " + d1);
        System.out.println("d2: " + d2);

        // Double instance creation
        Double value1 = new Double(d1);
        Double value2 = new Double(d2);


        // It returns the double value denoted by the given bit denotation 
        //by calling value1.longBitsToDouble(124568)
        double result1 = value1.longBitsToDouble(124568);

        // It returns the double value denoted by the given bit denotation 
        //by calling value1.longBitsToDouble(124568)

        double result2 = value2.longBitsToDouble(0xfff0000000000000L);

        // Display result1,result2 values
        System.out.println("value1.longBitsToDouble(124568): " + result1);
        System.out.println("value2.longBitsToDouble(0xfff0000000000000L): " + result2);
    }
}

Output

输出量

d1: 18.2
d2: 19.2
value1.longBitsToDouble(124568): 6.1545E-319
value2.longBitsToDouble(0xfff0000000000000L): -Infinity


翻译自: https://www.includehelp.com/java/double-class-longbitstodouble-method-with-example.aspx

你可能感兴趣的:(java,python,jvm,jdk,.net)