本文共 2764 字,大约阅读时间需要 9 分钟。
strictmath
exp() method is available in java.lang package.
exp()方法在java.lang包中可用。
exp() method is used to return the exponential of the given number in the method or other words it is used to calculate the e raised to the power of the given argument. Here, exp stands for exponentiation.
exp()方法用于返回该方法中给定数字的指数,或者换句话说,它用于计算提高到给定参数幂的e。 在这里,exp代表幂运算。
exp() method is a static method so it is accessible with the class name and if we try to access the method with the class object then also we will not get an error.
exp()方法是静态方法,因此可以使用类名进行访问,如果尝试使用类对象访问该方法,则也不会收到错误。
exp() method does not throw any exception.
exp()方法不会引发任何异常。
Syntax:
句法:
public static double exp(double d);
Parameter(s):
参数:
double d – represents the double type value whose exponential value to be found.
double d –表示要找到其指数值的double类型值。
Return value:
返回值:
The return type of this method is double – it returns exponential value of the given parameter.
此方法的返回类型为double-它返回给定参数的指数值。
Note:
注意:
If we pass NaN as an argument, method returns the same value (NaN).
如果我们将NaN作为参数传递,则方法将返回相同的值(NaN)。
If we pass a positive infinity, method returns the same (i.e. positive infinity).
如果我们传递一个正无穷大,则方法将返回相同的值(即正无穷大)。
If we pass a negative infinity, method returns 0.0.
如果我们传递一个负无穷大,则方法返回0.0。
Example:
例:
// Java program to demonstrate the example// of exp(double d) method of StrictMath Class.public class Exp { public static void main(String[] args) { // variable declarations double d1 = 7.0 / 0.0; double d2 = -7.0 / 0.0; double d3 = 0.8; double d4 = 2; // Display previous value of d1,d2,d3 and d4 System.out.println("d1: " + d1); System.out.println("d2: " + d2); System.out.println("d3: " + d3); System.out.println("d4: " + d4); // Here , we will get (Infinity) because we are // passing parameter whose value is (infinity) System.out.println("StrictMath.exp(d1): " + StrictMath.exp(d1)); // Here , we will get (0.0) because we are // passing parameter whose value is (-infinity) System.out.println("StrictMath.exp(d2): " + StrictMath.exp(d2)); // Here , we will get (e raised to the power of 0.8) because we are // passing parameter whose value is (0.8) System.out.println("StrictMath.exp(d3): " + StrictMath.exp(d3)); // Here , we will get ( e raised to the power of 2) because we are // passing parameter whose value is (2) System.out.println("StrictMath.exp(d4): " + StrictMath.exp(d4)); }}
Output
输出量
d1: Infinityd2: -Infinityd3: 0.8d4: 2.0StrictMath.exp(d1): InfinityStrictMath.exp(d2): 0.0StrictMath.exp(d3): 2.225540928492468StrictMath.exp(d4): 7.38905609893065
翻译自:
strictmath
转载地址:http://lwozd.baihongyu.com/