java double方法_Java Double doubleTorRawLongBits()方法与示例

java double方法

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

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

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

  • doubleTorRawLongBits() method follows IEEE 754 double floating-point standards and according to standards, it returns the bits that denote floating-point value along with preserving NaN value.

    doubleTorRawLongBits()方法遵循IEEE 754双浮点标准,并且根据这些标准,它返回表示浮点值的位以及保留NaN值。

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

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

  • doubleTorRawLongBits() method does not throw an exception at the time of representing bits along with preserving NaN.

    doubleTorRawLongBits()方法在表示位以及保留NaN时不会引发异常。

Syntax:

句法:

    public static long doubleToRawLongBits(double value);

Parameter(s):

参数:

  • double value – This parameter represents the double precision floating-point value.

    double value –此参数表示双精度浮点值。

Return value:

返回值:

The return type of this method is long, it returns the bits that represent the double precision floating-point value.

此方法的返回类型为long ,它返回表示双精度浮点值的位。

Note:

注意:

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

    如果我们传递正无穷大 ,它将返回值0x7ff0000000000000L

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

    如果我们传递负无穷大 ,它将返回值0xfff0000000000000L

  • If we pass NaN, it returns the actual NaN values (i.e. it does not collapse all the bit encoding a NaN to a "basic" NaN value).

    如果我们传递NaN ,它将返回实际的NaN值(即,它不会将编码NaN的所有位都折叠为“基本” NaN值)。

Example:

例:

// Java program to demonstrate the example 
// of doubleToRawLongBits(double value)
// method of Double class

public class DoubleToLongBitsOfDoubleClass {
    public static void main(String[] args) {
        // Variables initialization
        double value1 = 18.20;
        double value2 = 19.20;

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

        // It returns the bits denoted by the double 
        // floating-point argument by calling 
        // Double.doubleToRawLongBits(value1)
        long result1 = Double.doubleToRawLongBits(value1);
        long result2 = Double.doubleToRawLongBits(value2);

        // Display result1,result2 values
        System.out.println("Double.doubleToRawLongBits(value1): " + result1);
        System.out.println("Double.doubleToRawLongBits(value2): " + result2);
        System.out.print("Double.doubleToRawLongBits(NaN): ");
        System.out.println(Double.doubleToRawLongBits(5.0 % 0));
    }
}

Output

输出量

value1: 18.2
value2 :19.2
Double.doubleToRawLongBits(value1): 4625816062258262835
Double.doubleToRawLongBits(value2): 4626097537234973491
Double.doubleToRawLongBits(NaN): 9221120237041090560


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

java double方法

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值