Is there anyway I can do this without using ifs?
Like I want to do Math.Pow(-5f,2f) to come out as -25 not 25?
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.
How about with
Math.Sign:So the computation would be:
If the idea is to always use the sign of the first operand even when the
Powoperation returns a negative value (instead of just negating the result when the first operand is negative), you can do: