Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-24-2004, 03:28 PM   PM User | #1
cwl157
New Coder

 
Join Date: Jun 2003
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
cwl157 is an unknown quantity at this point
finding exponents in java

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.
cwl157 is offline   Reply With Quote
Old 11-24-2004, 06:17 PM   PM User | #2
Antoniohawk
Senior Coder

 
Join Date: Aug 2002
Location: Kansas City, Kansas
Posts: 1,518
Thanks: 0
Thanked 2 Times in 2 Posts
Antoniohawk will become famous soon enough
Google is your friend. [http://java.sun.com/j2se/1.4.2/docs/...ble,%20double)]
Antoniohawk is offline   Reply With Quote
Old 11-24-2004, 06:19 PM   PM User | #3
cwl157
New Coder

 
Join Date: Jun 2003
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
cwl157 is an unknown quantity at this point
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?
cwl157 is offline   Reply With Quote
Old 11-24-2004, 06:24 PM   PM User | #4
Antoniohawk
Senior Coder

 
Join Date: Aug 2002
Location: Kansas City, Kansas
Posts: 1,518
Thanks: 0
Thanked 2 Times in 2 Posts
Antoniohawk will become famous soon enough
Yup.
Antoniohawk is offline   Reply With Quote
Old 11-24-2004, 06:54 PM   PM User | #5
turbowrx
New Coder

 
Join Date: Nov 2004
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
turbowrx is an unknown quantity at this point
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?
turbowrx is offline   Reply With Quote
Old 11-24-2004, 07:00 PM   PM User | #6
cwl157
New Coder

 
Join Date: Jun 2003
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
cwl157 is an unknown quantity at this point
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.
cwl157 is offline   Reply With Quote
Old 02-02-2005, 11:43 PM   PM User | #7
JWizard
New Coder

 
Join Date: Feb 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
JWizard is an unknown quantity at this point
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.
JWizard is offline   Reply With Quote
Old 02-03-2005, 02:01 AM   PM User | #8
cfc
Regular Coder

 
Join Date: Dec 2004
Location: Keswick, Ontario
Posts: 251
Thanks: 0
Thanked 0 Times in 0 Posts
cfc is an unknown quantity at this point
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

Last edited by cfc; 02-03-2005 at 02:04 AM..
cfc is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:30 AM.


Advertisement
Log in to turn off these ads.