What does the ^ operator do in Java?

前端 未结 17 1760
执念已碎
执念已碎 2020-11-22 03:27

What function does the ^ (caret) operator serve in Java?

When I try this:

int a = 5^n;

...it gives me:

17条回答
  •  忘了有多久
    2020-11-22 03:43

    You can use Math.pow instead:

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

提交回复
热议问题