Math.pow()
Math.pow() returns the value of second input raised to the power of first input.
Syntax
Math.pow(input_number1,input_number2)
Here are some examples with different type of numbers.
System.out.println(Math.pow(2,2)); //4.0
System.out.println(Math.pow(2,4)); //16.0
System.out.println(Math.pow(-2,-5)); //-0.03125
System.out.println(Math.pow(-2,3)); //-8.0
Using double
System.out.println(Math.pow(2.12,2)); //4.494400000000001
System.out.println(Math.pow(2.12,4.34)); //26.079402457445806
System.out.println(Math.pow(-2.12,-5.67));//NaN
System.out.println(Math.pow(-2.12,3)); //-9.528128
« All Math functions
This article is written by plus2net.com team.
plus2net.com