cwl157
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.
|
||||
finding exponents in javacwl157 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. Antoniohawk 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)] cwl157 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? Antoniohawk 11-24-2004, 06:24 PM Yup. :) turbowrx 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? cwl157 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. JWizard 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. cfc 02-03-2005, 02:01 AM 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 |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum