Groovy - log()



此方法返回引數的自然對數。

語法

double log(double d) 

引數

d - 任何原始資料型別。

返回值

此方法返回引數的自然對數。

示例

以下是此方法的使用示例 -

class Example { 
   static void main(String[] args) { 
      double x = 11.635; 
      double y = 2.76;
	  
      System.out.printf("The value of e is %.4f%n", Math.E); 
      System.out.printf("log(%.3f) is %.3f%n", x, Math.log(x)); 
   } 
}

當我們執行以上程式時,將獲得以下結果 -

The value of e is 2.7183
log(11.635) is 2.454
groovy_numbers.htm
廣告
© . All rights reserved.