July 12th, 2013

PowerTip: Use PowerShell to Round a Decimal Number

Doctor Scripto
Scripter

Summary: Use the [decimal] Windows PowerShell type accelerator to round decimal numbers.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily round a decimal number an integer?

Hey, Scripting Guy! Answer Use the Round method from the [decimal] type accelerator:

PS C:\> [decimal]::round(10.555)

11

PS C:\> [decimal]::round(10.444)

10

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.