how do i find an exponent in java i think its the math.pow() method can someone show me an example of how to call this method correctly.
Printable View
how do i find an exponent in java i think its the math.pow() method can someone show me an example of how to call this method correctly.
Google is your friend. [http://java.sun.com/j2se/1.4.2/docs/...ble,%20double)]
yea i was looking at the pow() method but i dont know how to use it cause i have to take a number as input from the user and raise it to a power so how would i do that? Can i make a variable one of the parameters in the method?
Yup. :)
Both parameters are variables. Reading the api you'll notice that it returns a double.
x = Math.pow(y, z);
You'll get z to the yth power. That is not finding an exponent. What do you mean by finding an exponent?
yea sorry what you described is what i want to do. sorry my mind is pretty shot right now cause ive been working on this for hours and i just want to finish it.
Math.pow(double y,double z) returns a double value of y raised to the zth power, not the other way around, as turbowrx has said. Since we're being technical.
Perhaps logarithms could be of some use?
double exp = Math.log10(double number) / Math.log10(double base);
Edit: I just realized Math.log is base e, so I switched it to Math.log10