Finding Maximum Values

Numeric types can store numbers in certain ranges. A byte for example stores values in the range 0-255. But do you know just what the range is for an Int32 or Int64? You can very simply ask PowerShell:

[Int32]::MaxValue
2147483647
[Int64]::MaxValue
9223372036854775807
[Byte]::MaxValue
255

This will also explain the use of unsigned numeric types:

[Int32]::MaxValue
2147483647
[UInt32]::MaxValue
4294967295
[Int32]::MinValue
-2147483648
[UInt32]::MinValue
0

As you can see, unsigned types simply "shift" the negative range into the positive range. So if you do not need negative values, then unsigned data types provide a twice-as-large positive range.

Twitter This Tip! ReTweet this Tip!


Posted Sep 17 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.