codecamp

Groovy exp()方法

该方法返回自然对数e的底数为参数的幂。

句法

double exp(double d)

参数

d - 任何原始数据类型。

返回值

此方法返回自然对数的底,e,为参数的幂。

例子

下面是一个使用这个方法的例子 -

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("exp(%.3f) is %.3f%n", x, Math.exp(x));
   } 
}

当我们运行上面的程序,我们将得到以下结果 -

The value of e is 2.7183 
exp(11.635) is 112983.831
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }