gmp_rootrem


gmp apg

TAKE the integer part and the remainder of a given root.





Note that $nth > 0, otherwise an ERROR is issued.

This function returns a two element array, where the first element is the integer component of the root, and the second element is the remainder, both represented as GMP numbers.



<?php

array gmp_rootrem GMP|int|string $numint $nth )


where,

$num The GMP numeric value

$nth 
The root to consider as an INTEGER value

?>
 

$num


The GMP numeric value to extract a given root.



$nth


The root to consider as an integer value.



  1 EXERCISE   

<?php

function intptroottrem01 $a01$r01)
{
    
$rr01 gmp_rootrem($a01$r01);

echo 
'The root ' $r01 ' of ' $a01 ' is ' $rr01[0];
echo 
' ( INTEGER PORTION )<br>and ' $rr01[1] . ' is the remainder.<br><br>';

}

$a01a = [ '0200000''0200001'
                       
'0x10000''0x1000A'
                               
6553665537200
                                        
'023''0x13'
                                        
012419 ];
                                        
$nt01 mt_rand(13);

foreach(
$a01a as $a01)
{
intptroottrem01($a01$nt01);
}    

?>

  2 EXERCISE   

<?php

function intptroottrem02 $a02$r02)
{
    
$rr02 gmp_rootrem($a02$r02);

echo 
'The root ' $r02 ' of ' $a02 ' is ' $rr02[0];
echo 
' ( INTEGER PORTION )<br>and ' $rr02[1] . ' is the remainder.<br><br>';

}

$a02a = [ '0200000''0200002'
                       
'0x10000''0x1000A'
                               
6553665537200
                                        
'023''0x13'
                                        
012419 ];
                                        
$nt02 0;
// Attention to this value

foreach($a02a as $a02)
{
intptroottrem02($a02$nt02);
}    

?>