# pow (double, double)

Page 1 of 1

## 4 Replies - 368 Views - Last Post: 03 October 2012 - 07:40 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=292947&amp;s=4bf2a00498de7a0a808a672892de9dd1&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 thorax232

Reputation: 1
• Posts: 94
• Joined: 10-September 12

# pow (double, double)

Posted 23 September 2012 - 02:10 PM

I'm having a ton of trouble with this. I have the code:

```double discrim = Math.pow((b*B)/> - (4*a*c));
```

And am getting the following error:

```Prog10.java:15: pow(double,double) in java.lang.Math cannot be applied to (double)
double discrim = Math.pow((b*B)/> - (4*a*c));
^
1 error
```

I've read a couple of forums relating to this error but I don't understand the answers, talking about how pow need two arguments? I just want to assign the variable "dicrim" to the formula. Is there something unique I have to do for exponents? I figured b*b would be a good substitute for b^2. =/

Thanks for your time and patience.

I should mention in the code it is both lowercase b's. I think the forum auto corrected that somehow.

Is This A Good Question/Topic? 0

## Replies To: pow (double, double)

### #2 Martyr2

• Programming Theoretician

Reputation: 4930
• Posts: 13,327
• Joined: 18-April 07

## Re: pow (double, double)

Posted 23 September 2012 - 02:11 PM

Pow takes two values. The base value (the value raised to some value) and the exponential value (the power). For instance to raise 10 to the power of 2 you would do Math.pow(10.0,2.0). In your code above you have one value only. (b*B ) - (4*a*c) is boiled down to a single number. Is (b*B ) - (4*a*c) the base or the power? You need to add a comma and then a second number. Both numbers should be a double.

This post has been edited by Martyr2: 23 September 2012 - 02:12 PM

### #3 thorax232

Reputation: 1
• Posts: 94
• Joined: 10-September 12

## Re: pow (double, double)

Posted 24 September 2012 - 07:16 AM

Martyr2, on 23 September 2012 - 02:11 PM, said:

Pow takes two values. The base value (the value raised to some value) and the exponential value (the power). For instance to raise 10 to the power of 2 you would do Math.pow(10.0,2.0). In your code above you have one value only. (b*B ) - (4*a*c) is boiled down to a single number. Is (b*B ) - (4*a*c) the base or the power? You need to add a comma and then a second number. Both numbers should be a double.

Hm, well I'm trying to square a variable given by a user. I ask them to enter a, b and c. Could I use 1? Like:
(b,b*1)-(4*a*c) or (b*b*1)-(4*a*c)

I'll give a try when I'm home later but I have a feeling that won't work either. Maybe you could show what your thinking of?

Also I've tried (b,2)-(4*a*c) but I got the same error with it. =/ Maybe I should add 1 to that version... lol I don't know.

Woops, I meant b,2*1 on the first snippet.

### #4 pbl

• There is nothing you can't do with a JTable

Reputation: 8370
• Posts: 31,956
• Joined: 06-March 08

## Re: pow (double, double)

Posted 24 September 2012 - 07:28 AM

If power of two easier to write val*val rather than Math.pow(val, 2.0)
but pow(val, 2.0) is valid

double bSquare = b * b:
double fourAC = 4.0 * a * c;

double r1 = bSquare + fourAC;
double r2 = bSquare - fourAC;

### #5 thorax232

Reputation: 1
• Posts: 94
• Joined: 10-September 12

## Re: pow (double, double)

Posted 03 October 2012 - 07:40 PM

Sorry I forgot to post back on this. I was being kind of dumb. What I needed was.

(b,2.0) I was forgetting the .0 lol, thanks for the responses though.