- mt_rand: documentation ( source)
- round: documentation ( source)
<?php
do{
$a = mt_rand(5, 75);
$b = mt_rand(5, 75);
$adjuster = mt_rand(2, 20);
$decimal_selector = mt_rand(1, 6);
if ($decimal_selector == 1){
$a = $a / 10;
$b = $b / 10;
}
if ($decimal_selector == 2){
$a = $a / 10;
$b = $b / 100;
}
if ($decimal_selector == 3){
$a = $a / 100;
$b = $b / 10;
}
if ($decimal_selector == 4){
$a = $a / 100;
$b = $b / 100;
}
if ($decimal_selector == 5){
$a = $a / 1000;
$b = $b / 1000;
}
if ($decimal_selector == 6){
$a = $a / 1000;
$b = $b / 100;
}
if($b < $a){
$b = $b + ($a - $b) + $adjuster;
}
echo "a: $a. b: $b. ";
$c = $b - $a;
if(round($c) == $c) {
$c_is_int = 1;
echo "c: $c (is int!)\n";
} else {
$c_is_int = 0;
echo "c: $c (is NOT int!)\n";
}
} while($c_is_int == 1);