The calculation of numbers in Powershell we are often used to simply use arithmetic notation, but for relatively complex numeric operations we need relatively complex functions or commands, and here we introduce a method of computing directly through. Net classes, Simple and straightforward to perform complex numerical operations with extremely concise expressions. It also allows us to get in touch with PowerShell gradually , because PowerShell is based on . Net Object-oriented programming languages.
First, format
The Math class is very simple to use, with the emphasis on formatting, and any methods that are directly based on the. Net class need to use the ["class"]::methed expression.
Second, Math 's focus on how to use
take absolute value: [Math]:abs ("-1") returns:1
take a larger value: [Math]:max ("1", "2") return:2
take a smaller value: [Math]:min ("1", "2") return:1
in a rounding: [Math]: Ceiling ("1.2") returns:2
Rounding : [Math]:floor ("1.2") return:1
more detailed use of the math class can be found in the MSDN White paper:
Https://msdn.microsoft.com/en-us/library/system.math (v=vs.110). aspx
This article is from the "Essence of the" blog, please be sure to keep this source http://simy88.blog.51cto.com/7370552/1686243
"Powershell" "math class" directly calls the. Net method of the math class for numeric operations