Jump to content

[SOLVED] Large Number Comparison


dshevnock

Recommended Posts

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

<?php

$startRange = '1111111111111111119';
$endRange = '1111111111111111111';

if ($startRange > $endRange){
   echo "The starting range is bigger!";

} else if ($startRange < $endRange){
   echo "The ending range is bigger!";
}

?>

<?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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.