當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Java Java.lang.StrictMath.getExponent()用法及代碼示例


描述

這個java.lang.StrictMath.getExponent(double d) 方法返回用於表示 double 的無偏 index 。它包括一些情況 -

  • 如果參數為 NaN 或無窮大,則結果為 Double.MAX_EXPONENT + 1。
  • 如果參數為零或次正規,則結果為 Double.MIN_EXPONENT -1。

聲明

以下是聲明java.lang.StrictMath.getExponent()方法

public static int getExponent(double d)

參數

d- 這是雙值。

返回值

此方法返回用於表示 double 的無偏 index 。

異常

NA

示例

下麵的例子展示了 java.lang.StrictMath.getExponent() 方法的用法。

package com.tutorialspoint;

import java.lang.*;

public class StrictMathDemo {

   public static void main(String[] args) {

      double d1 = 16.2 , d2 = 512.3;
   
      // returns the unbiased exponent used in the representation of a double
      double exponentValue = StrictMath.getExponent(d1); 
      System.out.println("Exponent value of " + d1 + " = " + exponentValue);
        
      exponentValue = StrictMath.getExponent(d2); 
      System.out.println("Exponent value of " + d2 + " = " + exponentValue);
   }
}

讓我們編譯並運行上麵的程序,這將產生以下結果 -

Exponent value of 16.2 = 4.0
Exponent value of 512.3 = 9.0

相關用法


注:本文由純淨天空篩選整理自 Java.lang.StrictMath.getExponent() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。