February 8th, 2014

PowerTip: Use PowerShell to Get Length of a Number

Doctor Scripto
Scripter

Summary:  Use Windows PowerShell to easily get the length of a number.

Hey, Scripting Guy! Question I want to know the length of a number, but when I use the Length property, it comes back as 1.
          How can I get the actual length?

Hey, Scripting Guy! Answer First convert the number to a string, and then get the length of the string:

(12345).tostring().length

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.