"Powershell" "math class" directly calls the. Net method of the math class for numeric operations

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.