Hello I am trying to build a function to check if a number is multiple of another:
What I am trying to get:
my_function (10,2) = true
my_function (8,3) = false
my_function (9.5,0.5) = true
my_function (6,1.5) = true
my_function (1.1,0.1) = true
My function is:
//Check if $number1 is a multiple of $number2
function my_function( $number1, $number2 ){
$_number = $number1 / $number2;
if( $_number == floor( $_number ) ) :
return true;
else :
return false;
endif;
}
It is working like a charm, except that for some reason when there are values 3,7,11, etc it is returning false when it should clearly return true:
my_function (5.4,0.3) = false (it is retruning false, it should be true!)
my_function (7.7,0.7) = false (it is retruning false, it should be true!)
Any idea why? Is it a compiler error? I run out of ideas. Thank you