Current location - Training Enrollment Network - Mathematics courses - How about prescribing in java?
How about prescribing in java?
For the square root, you can use the sqrt function in the java.lang.Math class of the math toolkit, and for the square root, you can use the power function in the math class.

The call format is as follows:

math . sqrt(2.0); //square 2

Math.pow(9.0, 1.0/3.0); //Open 9 to the third power, open other powers, and so on.

Sqrt function prototype:

Public static double sqrt (double a)

Returns the positive square root of a correctly rounded double-precision value.

Results of different values of parameter a:

1. If the parameter is NaN or less than zero, the result is NaN.

2. If the parameter is positive infinity, the result is positive infinity.

3. If the parameter is positive zero or negative zero, the result is the same as the parameter.

Otherwise, the result is a double-precision value closest to the true mathematical square root of the parameter value.

Power function prototype

Public static dual power supply (double A, double B)

The function returns a to the power of b, please refer to java api for details.