Forum breadcrumbs - You are here:Heelpbook Q&AQuestions: Ask for a SolutionPowershellPowershell - How to round a numbe …
Please Login to create posts and topics.
Powershell - How to round a number to a specific decimal place?
HeelpBook@heelpbook
116 Posts
HeelpBook@heelpbook
116 PostsTopic Author
#2 · October 18, 2018, 2:47 pm
Quote from HeelpBook on October 18, 2018, 2:47 pmIn Powershell we can use the Round static method from the System.Math class. By default, it does not display decimal places (if used without the relative parameter), but you can easily change that behavior. See the following examples to see how to achieve this:
PS C:\> $a = 111.2226
PS C:\> [math]::Round($a)
111
PS C:\> [math]::Round($a,2)
111.22
PS C:\> [math]::Round($a,3)
111.223
In Powershell we can use the Round static method from the System.Math class. By default, it does not display decimal places (if used without the relative parameter), but you can easily change that behavior. See the following examples to see how to achieve this:
PS C:\> $a = 111.2226 PS C:\> [math]::Round($a) 111 PS C:\> [math]::Round($a,2) 111.22 PS C:\> [math]::Round($a,3) 111.223 |
Click for thumbs down.0Click for thumbs up.0