-1

Do we have predefined Power Operator in C#?

When I try with ^ Operator, It is taking exclusive-or operation.

Is there any way to include the Pow Operator other than Math Library?

karthik
  • 17,006
  • 70
  • 76
  • 122

1 Answers1

4

There is no built in power operator similar to that found in Fortran, Python etc.

  • For floating operands you should use Math.Pow.
  • For efficient exponentiation of integer operands there is nothing included in the framework. Instead you can roll your own. For example: How do you do *integer* exponentiation in C#?
Community
  • 1
  • 1
David Heffernan
  • 587,191
  • 41
  • 1,025
  • 1,442