There was a problem writing the java math power function.

Asked 2 years ago, Updated 2 years ago, 149 views

There is a situation where I have to use the java math.power function for the assignment. However, the input value should be put in the long type variable, but it seems that the desired value does not come out in some cases because it is math.power (double a, double b). For example, System.out.println((long)Math.paw(Long.parseLong("-1"),Long.parseLong("1234567890101011")); the output should be -1 because it is multiplied by an odd number of times, but the output value should be 1.

If you enter System.out.println((long)Math.paw(Long.parseLong("3"),Long.parseLong(35")); the output is 5003154509899704; if you roll the calculator, you get 5003154509899707.

What's the problem and how do we solve it?

java math power

2022-09-22 19:54

1 Answers

https://stackoverflow.com/questions/9956471/wrong-result-by-java-math-pow

I think it will be an answer if you refer to the answers and comments on the link.


2022-09-22 19:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.