Division operator (/) returns a float value unless the two operands are integers. Operands of Modulus (%) are converted to integers before they are processed. The result of Modulus Operator (%) has the same sign as the dividend. |
<?php $a = 2; $b = 2; $c = -12; $b = 22; echo $a + $b ."<br>"; echo $c + $d ."<br>"; } ?>
Output
4 10
<?php $a = 2; $b = 2; $c = -8; $d = 2; echo $a - $b ."<br>"; echo $c - $d ."<br>"; } ?>
Output
0 -10
<?php $a = 2; $b = 2; $c = -4; $d = 5; echo $a / $b ."<br>"; echo $c / $d ."<br>"; } ?>
Output
1 -0.8
<?php $a = 2; $b = 2; $c = -2; $d = 2; echo $a * $b ."<br>"; echo $c * $d ."<br>"; } ?>
Output
4 -4
<?php $a = 2; $b = 4; $c = 4; $d = 2; $e = -3; $f = 2; $g = -3; $h = -2; echo $a % $b ."<br>"; echo $c % $d ."<br>"; echo $e % $f ."<br>"; echo $g % $h ."<br>"; } ?>
Output
2 0 -1 -1