The Math class
Math class: contains methods like sqrt and pow
To compute
xn,
you write
Math.pow(x, n)
static double
pow(double a, double b)
Returns the value of the first argument raised to the power of the
second argument.
However, to compute
x2
it is significantly more efficient simply
to compute
x * x
To take the square root of a number, use the
Math.sqrt;
for
example,
Math.sqrt(x)
static double
sqrt(double a)
Returns the correctly rounded positive square root of a double
value.
In Java, can
be represented as (click
here)
(-b
+ Math.sqrt(b * b - 4 * a * c)) / (2 * a)
static double
exp(double a) Returns Euler's number e raised to the power of a
double value.
|
Calling Static Methods
|