11

I (apparently wrongly) assumed there would be a built-in power operator or function in Powershell, but I it seems there is not, or is there?

skeetastax
  • 1,016
  • 8
  • 18

2 Answers2

13

As you've found, real exponentation can be achieved with some accuracy by calling [Math]::Pow().

For large integer exponentiation, you might want to use [bigint]::Pow() instead:

PS ~> [Math]::Pow(256, 20)
1.4615016373309E+48
PS ~> [bigint]::Pow(256, 20)
1461501637330902918203684832716283019655932542976
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
7

Never mind, I found the answer:

[Math]::Pow(256,3) # 256 to the power of 3 (= ~16.7 million)
skeetastax
  • 1,016
  • 8
  • 18