gmp_export


gmp apg

EXPORT a GMP number to a binary string.

This function is the inverse of gmp_import.





$word_size = 1 is the default, mainly used in conjunction with the $flags parameter.

$num must be multiple of the length of the $word_size.



<?php

str gmp_export 
GMP|int|string $num
                                             
int $word_size 1
                                             
int $flags GMP_MSW_FIRST GMP_NATIVE_ENDIAN )


where,

$num The GMP number to be exported

$word_size 
The number of bytes in each chunk of binary data

$flags 
To control how the binary string will be exported 

?>
 

$num


The GMP number to be exported.



$word_size


The number of bytes in each chunk of binary data.



$flags


To control how the binary string will be exported.



RELATED FLAGS
CONTANT NAMEVALUE
GMP_ROUND_ZERO0
GMP_ROUND_PLUSINF1
GMP_ROUND_MINUSINF2
GMP_MPIR_VERSION3.0.0
GMP_VERSION6.0.0
GMP_MSW_FIRST1
GMP_LSW_FIRST2
GMP_LITTLE_ENDIAN4
GMP_BIG_ENDIAN8
GMP_NATIVE_ENDIAN16
ed48

  1 EXERCISE   

<?php

$b01 
'997656246614747892046622708740401';

$i01 gmp_export($b01);

echo 
'gmp_export( ' $b01 ' ) = ' $i01;

?> 

  2 EXERCISE   

<?php

$bv02 
= [ '997656246614747892046622708740401'
               
'977453065168906566222568282403121',
               
'997656246614747892047717925466161' ];

$wv02 = [ 12];

foreach(
$bv02 as $b02)
{
foreach(
$wv02 as $w02)
{

$i02 gmp_export($b02 $w02 );

echo 
'gmp_export ' $b02 ', ' 
                               
$w02 ') =<br><br>= ' 
                               
$i02 '<br><br><br>';

}
}
?> 

  3 EXERCISE   

<?php

$bv03 
= [ '44469170785662433440067810223148777773'
                
'60154957638466669228148190227381580833' ];

$wv03 1;

$op03 = [ GMP_LSW_FIRST
               
GMP_MSW_FIRST,
               
GMP_LITTLE_ENDIAN
               
GMP_NATIVE_ENDIAN
               
GMP_BIG_ENDIAN ];

foreach(
$bv03 as $b03)
{

    foreach(
$op03 as $o03)
    {

$i03 gmp_export($b03 $wv03$o03 );

echo 
'gmp_export( ' $b03 ', ' 
                                  
$wv03 ', ' 
                                  
$o03 ') =<br><br>= ' 
                                  
$i03 '<br><br><br>';
    }
}

?>