dshevnock Posted June 20, 2007 Share Posted June 20, 2007 I need to be able to compare some 19 digit numbers (in regards to < or >). I obviously keep on running into the problem that when ever I try to use the examples: $startRange = 1111111111111111119 $endRange = 1111111111111111111 What do I need to do to be able to compare these larger numbers? What I want to check more specifically is that the $startRange is not larger then $endRange. Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/56445-solved-large-number-comparison/ Share on other sites More sharing options...
pocobueno1388 Posted June 20, 2007 Share Posted June 20, 2007 <?php $startRange = '1111111111111111119'; $endRange = '1111111111111111111'; if ($startRange > $endRange){ echo "The starting range is bigger!"; } else if ($startRange < $endRange){ echo "The ending range is bigger!"; } ?> Link to comment https://forums.phpfreaks.com/topic/56445-solved-large-number-comparison/#findComment-278786 Share on other sites More sharing options...
utexas_pjm Posted June 20, 2007 Share Posted June 20, 2007 Use this: http://us2.php.net/manual/en/function.bccomp.php Best, Patrick Link to comment https://forums.phpfreaks.com/topic/56445-solved-large-number-comparison/#findComment-278787 Share on other sites More sharing options...
dshevnock Posted June 21, 2007 Author Share Posted June 21, 2007 <?php $startRange = '1111111111111111119'; $endRange = '1111111111111111111'; if ($startRange > $endRange){ echo "The starting range is bigger!"; } else if ($startRange < $endRange){ echo "The ending range is bigger!"; } ?> I tried something very similar to this in the beginning, but because integers are only evaluated to 16 digits (from my understanding) and I need 19 digits, it would not work. Link to comment https://forums.phpfreaks.com/topic/56445-solved-large-number-comparison/#findComment-279393 Share on other sites More sharing options...
dshevnock Posted June 21, 2007 Author Share Posted June 21, 2007 Use this: http://us2.php.net/manual/en/function.bccomp.php Best, Patrick bccomp worked PERFECTLY! Thanks Patrick! Link to comment https://forums.phpfreaks.com/topic/56445-solved-large-number-comparison/#findComment-279405 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.