gmp_divexact


gmp apg

GET the exact division of two GMP number.





This function returns uses the Exact-Division Algorithm to execute ( $num1 / $num2 ).

Exact-Division Algorithm 



<?php

GMP gmp_divexact 
( GMP|int|string $num1, GMP|int|string $num2 )


where,

$num1 = The divisor

$num2 
= The dividend

?>
 

$num1


The divisor.



$num2


The dividend.



  1 EXERCISE   

<?php

$ver 
= PHP_VERSION;

$a01a = PHP_INT_MAX;

$a01b = [ 2.33, 64.3 ];

if(
$ver > 8)
{
foreach(
$a01b as $b01a)
{
    
$g01a = gmp_divexact($a01a, $b01a);
    
$s01a = gmp_strval($g01a);
    echo 
'gmp_divexact ( ' . $a01a . ', ' . $b01a . ' ) = ' . $g01a . ' or <br>';
    echo 
'gmp_strval( ' . $g01a . ' ) = ' . $s01a . '<br><br>';
}
}
else
{
    echo 
'Is not possible to execute this code.<br>PHP ' . $ver;
}

?> 

  2 EXERCISE   

<?php

$ver 
= PHP_VERSION;

$a02a = PHP_INT_MAX;

$a02b = [ "233", "643" ];

foreach(
$a02b as $b02a)
{
    
$g02a = gmp_divexact($a02a, $b02a);
    
$s02a = gmp_strval($g02a);
    echo 
'gmp_divexact ( ' . $a02a . ', ' . $b02a . ' ) = ' . $g02a . ' or <br>';
    echo 
'gmp_strval( ' . $g02a . ' ) = ' . $s02a . '<br><br>';
}

?>