I was looking to convert some string data into integers – the data was bytes & I needed it in GB. The value I needed was buried in the middle of a string so I needed to do some string processing. Some other conditions forced me to use the Parse method of the integer class
Lets say I get a number like 2147483169 back in the data & I need to divide by 1gb
£> [int]::Parse(“2147483169″) / 1gb
I’ve put the string value directly in here rather than the complicated string processing I was actually using.
The point came when I realised that I could have much bigger numbers than 2Gb so what was the maximum I could work with
£> [int]::maxValue / 1gb
OK thats not enough. The standard [int] is 32bits & I know its big brother has 64 bits so how big is big brother
£> [int64]::maxValue / 1gb
That’s more than big enough so I went with 64 bit integers.
This isn’t just a developer type thing because I was working with Exchange mail box sizes. So the moral of the story is to think about the possible values you’ll see in you data while you are coding to avoid errors or failure when you are running the script.