Question

As above, I'm trying to make a number to the power of a variable, but it's not working, and is producing the error "The operator ^ is undefined for the argument type(s) double, long".

Here's the line of code:

longSwordCost = 30*(1.3^longSwordCount);

Help!

Was it helpful?

Solution

You need public static double Math.pow(double a, double b):

http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#pow%28double,%20double%29

The ^ is an XOR logic operator in Java.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top