Hi all,
I have to compare two large numbers to see if one is higher than the other.
An example of such a number is 89441000301200094490.
They are actually mobile phone SIM numbers.
I want to check to see if say 89441000301200094491 is higher than the number above (which it is).
I understand that I can't just use intval as these numbers are larger than is permitted.
So I built a funtion that works through each digit in each of the two numbers and checks if this is higher. It doesn't seem to be working though.
Can anyone see the problem with the code below or can anyone suggest another method for comparing these large numbers.
$theDbSimNum = "89441000301200122598";
$theNewSimNum = "89441000301200397599";
for ( $counter = 0; $counter <= 19; $counter++) {
$trimNew = intval(substr($theNewSimNum, $counter, 1));
$trimHigh = intval(substr($theDbSimNum, $counter, 1));
if($trimNew < $trimHigh){
$theVerdict = "LOWER";
} else if ($trimNew > $trimHigh){
$theVerdict = "HIGHER";
} else {
$theVerdict = "UNKNOWN";
}
}
echo $theVerdict;