0

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,453
  • 70
  • 78
  • 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
  • 601,492
  • 42
  • 1,072
  • 1,490