I head a real brain teaser when working a script earlier today. Basically I was modifying a script which lists out unused phone numbers in a range. It turns out German phone numbers (and any number greater than 2147483647) are incompatible with number ranges
prompted the development of a sublingual pill.• Lifestyle factors viagra pills.
. Here’s why, and how to solve it.
When using number ranges, you are limited to signed 32 bit integers (-2147483646 to +2147483647). This is rarely an issue, but when working with untypical numbers, like unformatted phone numbers or the byte value of very large files, it can pose a problem.
This is an example of a range that will work:
1 |
10..20 |
This however, won’t work:
1 |
2147483640..2147483648 |
The high number is above the max value for a signed 32 bit integer.
Solving required a bit of a hack. To work around this limitation, use a While loop to create an array with the number series you’d like to feed into to your variable. Below is an example:
1 2 3 4 5 |
$counter = $NumberStart while ($counter -lt $NumberEnd) { $counter++ [ARRAY]$Array += $temp } |
$Counter is initially set to be the starting number of your range. It will be the control parameter that the While loop uses to check if it’s done working
.
$NumberStart is the starting (low) number in you range.
$NumberEnd is the end (high) number in you range
$Array is your range (or it’s equivalent). It gets fed each value from $NumberStart to $NumberEnd. This array will hold 64 bit integers.