gmp_sqrt


gmp apg

CALCULATES the integer portion of the square root of a GMP number.





This function returns the integer portion of the square root of $num > 0 or $num = 0, as a GMP number.



<?php

GMP gmp_sqrt 
GMP|int|string $num )


where,

$num GMP number to obtain the INTEGER portion of square root

?>
 

$num


The GMP number to obtain the integer portion of square root.



  1 EXERCISE   

<?php

function intptsqrt01 $a01 )
{
    
$sqr01 gmp_sqrt($a01);

echo 
$sqr01 ' is the integer portion of square root of ' 
$a01 '<br><br>';

}

$a01a = [ '0200000''0200001''0x10000''0x1000A'
                                    
6553665537200'023''0x13',
                                    
0319 ];

foreach(
$a01a as $a01)
{
intptsqrt01($a01);
}    

?> 

 RESULT   

256 is the integer portion of square root of 0200000

256 is the integer portion of square root of 0200001

256 is the integer portion of square root of 0x10000

256 is the integer portion of square root of 0x1000A

256 is the integer portion of square root of 65536

256 is the integer portion of square root of 65537

14 is the integer portion of square root of 200

4 is the integer portion of square root of 023

4 is the integer portion of square root of 0x13

4 is the integer portion of square root of 19


  2 EXERCISE   

<?php

function intptsqrt02 $a02 )
{
    
$sqr02 gmp_sqrt($a02);

echo 
$sqr02 ' is the integer portion of square root of ' 
$a02 '<br><br>';

}

$a02a = [ -256, -2, -];

foreach(
$a02a as $a02)
{
intptsqrt02($a02);
}    

?>