Export (0) Print
Expand All
Expand Minimize

Converting VBScript's Sqr Function


Windows PowerShell


Definition: Returns the square root of a number.

Sqr

Finally, a mathematical construct we all recognize! Granted, you probably need to calculate square roots about as often as you need to calculate arctangents. (On the other hand, and unlike arctangents, at least most of us know what square roots are.) Best of all, even if you don't know what square roots are you can still calculate them by using the System.Math class and the Sqrt method. For example, this command determines the square root of 144 and stores the result in the variable $a:


$a = [math]::sqrt(144)

When you run this command and then echo back the value of $a you should get the following:


12


Return to the VBScript to Windows PowerShell home page

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft