View Full Version : finding exponents in java
11-24-2004, 03:28 PM
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.
11-24-2004, 06:17 PM
Google is your friend. [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Math.html#pow(double,%20double)]
11-24-2004, 06:19 PM
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?
11-24-2004, 06:24 PM
11-24-2004, 06:54 PM
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?
11-24-2004, 07:00 PM
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.
02-02-2005, 11:43 PM
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);
I just realized Math.log is base e, so I switched it to Math.log10
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.