Number manipulation and parsing
PowerShell is a powerful mathematics calculator. In fact, PowerShell has an entire Windows class dedicated to mathematics calculations that can be called by using the [System.Math]
.NET class. When you are working with the [System.Math]
classes, it is common to call static fields within a class. Static fields are static properties, methods, and objects that can be called to display data or do actions. To call a static field, you call the [Math]
(shortened version of [System.Math]
) class, followed by two colons ::
and the static field name.
To use the math operation to calculate pi, execute the following command:
[math]::pi
The output of this is shown in the following screenshot:
This simple command will provide PI if you ever need it for a calculation by using the pi
method of the math class. The result of this command returns 3.14159265358979
.
To use the math operation to calculate Euler's number, execute the following command:
[math]::e
The output of this...