Round


Definition: Returns a number rounded to a specified number of decimal places.

 

When working with system administration scripts (and performing chores like returning free disk space on a drive) you’ll often get back numbers similar to this: 45.987654321. More often than not you don’t really need all those decimal places; instead, you’d just as soon round the value up (or down).

 

OK; in Windows PowerShell all you have to do is use the System.Mathclass and the Roundmethod. This command rounds the number 45.987654321 to two decimal places (notice the value 2passed as the second parameter to the method). The resulting value is then stored in the variable $a:

 

$a = [math]: :round(45.987654321, 2)

 

When you run this command and then echo back the value of $ a youshould get the following:

 

45.99