PowerShell Maths
A colleague recently popped in a support request after noticing that the Calculator app wasn’t installed on their computer. This prompted an office discussion on how else you can solve sums when sat in front of a computer, and I mentioned you could just use PowerShell.
Open a regular PowerShell window and you can just start typing in basic sums
So addition, subtraction, multiplication, and division work fine- but what else can you do without making it complicated or hard to remember?
PowerShell this comes with the backing of the .NET Maths library, so you can enter [System.Math]::
(or just [Math]::
) and then tab through possible operations - for example square root (see screenshot), power, trigonometry and so on.
There’s currently 35 methods in this library and you can get a full list of these using the GetMethods property. This example lists them nicely in comma delimited form so you don’t have to scroll this webpage too much :)
1PS C:\> ([System.Math].GetMethods() |
2Select-Object -Unique -Property Name ).Name -join ", "
3Abs, Acos, Acosh, Asin, Asinh, Atan, Atan2, Atanh, Cbrt, Ceiling, Cos, Cosh,
4Exp, Floor, Log, Log10, Pow, Sin, Sinh, Sqrt, Tan, Tanh, BigMul, DivRem, Clamp,
5IEEERemainder, Max, Min, Round, Sign, Truncate, ToString, Equals, GetHashCode,
6GetType
So, who needs a graphical Calculator app now?