In JavaScript
215 ^ 150 = 65
But when i try Math.POW(215, 150) in C# I am getting Infinite
Why it is not 65 ? How should I get 65 in C# ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are forgetting that the
^operator is not a to-the power-of operator, but rather a bitwise XOR.215 to the power of 150 is obscenely large, hence the Infinite.
If you wanted the 65, then use
215 ^ 150. However, if you wanted the 215 to the power of 150, then you’re going to need to use a much bigger number variable type thatMath.POW(x,y)can support. I’m not even sure if the BigInteger library can handle an operation of that magnitude, but it’s worth a try if that is what you are after.