Power operator in Java?

When I run the following Visual Basic code:

Dim b As Double b = (2 ^ 16 - 1) * Math.Sqrt(Math.Sqrt((a / (2 ^ 8 - 1)))) 

(Assuming a is double whose value is 15.0)
The result for b is about 32,275.

But when I run the following Java code, which should do the same as above:

 double b; b = (2 ^ 16 - 1) * Math.sqrt(Math.sqrt((a / (2 ^ 8 - 1)))); 

Again with a equal to 15, I get a completely different result: about 17.

Both solutions to this equation:

enter image description here

Why is this so? What I'm working for, Visual Basic gives the result I'm looking for.

+7
source share
1 answer

^ XOR operator in java. Use Math.pow(2,8) , which is 2 ^ 8 in Visual Basic.

+24
source

All Articles