<?php
GMP gmp_div_r ( GMP|int|string $num1,
GMP|int|string $num2 ,
int $rounding_mode = GMP_ROUND_ZERO )
where,
$num1 = The divisor
$num2 = The dividend
$rounding_mode = The result rounding
( SEE the below TABLE )
?>
CONSTANT NAME | VALUE | MEANING |
GMP_ROUND_ZERO | 0 | The result is truncate towards 0 |
GMP_ROUND_PLUSINF | 1 | The result is round towards +infinity |
GMP_ROUND_MINUSINF | 2 | The result is round towards -infinity |
ed48 |
<?php
$a01a = PHP_INT_MAX;
$a01b = [ 2, 8, 18, 32 ];
echo 'GMP_ROUND_ZERO<br><br>';
foreach($a01b as $b01a)
{
$g01a = gmp_div_r($a01a, $b01a);
$s01a = gmp_strval($g01a);
echo 'gmp_div_r ( ' . $a01a . ', ' . $b01a . ', 0 ) = ' . $s01a . '<br>';
}
echo '<br><br>GMP_ROUND_PLUSINF<br><br>';
foreach($a01b as $b01b)
{
$g01b = gmp_div_r($a01a, $b01b, 1);
$s01b = gmp_strval($g01b);
echo 'gmp_div_r ( ' . $a01a . ', ' . $b01b . ', 1 ) = ' . $s01b . '<br>';
}
echo '<br><br>GMP_ROUND_MINUSINF<br><br>';
foreach($a01b as $b01c)
{
$g01c = gmp_div_r($a01a, $b01c, 2);
$s01c = gmp_strval($g01c);
echo 'gmp_div_r ( ' . $a01a . ', ' . $b01c . ', 2 ) = ' . $s01c . '<br>';
}
?>
<?php
$a02a = 0X100;
// HEXADECIMAL VALUE 0X100 = 0x100 = DECIMAL VALUE 256
$a02b = [ 3, 4, 5 ];
$tp02c = [ "GMP_ROUND_ZERO" => GMP_ROUND_ZERO,
"GMP_ROUND_PLUSINF" => GMP_ROUND_PLUSINF,
"GMP_ROUND_MINUSINF" => GMP_ROUND_MINUSINF ];
foreach($a02b as $b02a)
{
foreach($tp02c as $k02c => $t02c)
{
echo $k02c . '<br>';
$g02a = gmp_div_r($a02a, $b02a, $t02c);
$s02a = gmp_strval($g02a);
echo 'gmp_div_r ( ' . $a02a . ', ' . $b02a . ', ' . $t02c . ' ) = ' . $g02a . '<br>';
echo 'gmp_strval( ' . $g02a . ' ) = ' . $s02a . '<br><br>';
}
}
?>