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 ...
Get PowerShell: Automating Administrative Tasks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.