octdec


php128 apg

RETURNS a STRING containing a DECIMAL representation of the given OCTAL number argument.



<?php

int
|float octdec string $octal_string )


where,

$octal_string The octal string value 
                                to be converted to decimal

?>
 

$octal_string


The OCTAL string value to convert to DECIMAL.



MAXIMUM OCTAL VALUE MAXIMUN DECIMAL VALUE bit
37777777777 4294967295 32
777777777777777777777 9223372036854775807 64
ed48



This function function can convert numbers that are too large to fit into the platforms INTEGER type, larger values are returned as FLOAT in that case.

Look at the above table to see the limits.




  1 EXERCISE   

<?php

$stroc01_32m 
'1777777777740000000002';

$stroc01_32M '37777777777';

$stroc01_64m '1000000000000000000002';

$stroc01_64M '777777777777777777777';

$stroc01_X 777777777777777777777;

$stroc01_l '998999998';

$stroc01_L '2732';

$octdec_32m octdec($stroc01_32m);

$octdec_32M octdec($stroc01_32M);

$octdec_64m octdec($stroc01_64m);

$octdec_64M octdec($stroc01_64M);

$octdec_X octdec($stroc01_X);

$octdec_l octdec($stroc01_l);

$octdec_L octdec($stroc01_L);

echo 
'octdec( ' $stroc01_32m ' ) = <br>' 
                      
$octdec_32m '<br><br>';

echo 
'octdec( ' $stroc01_32M ' ) = <br>' 
                      
$octdec_32M '<br><br>';

echo 
'octdec( ' $stroc01_64m ' ) = <br>' 
                      
$octdec_64m '<br><br><br>';

echo 
'octdec( ' $stroc01_64M ' ) = <br>' 
                     
$octdec_64M '<br><br>';

echo 
'octdec( ' $stroc01_X ' ) = <br>' 
                     
$octdec_X '<br><br><br>';

echo 
'octdec( ' $stroc01_l ' ) = <br>' 
                     
$octdec_l '<br><br>';

echo 
'octdec( ' $stroc01_L ' ) = <br>' 
                     
$octdec_L '<br><br>';

?> 

 RESULT   

octdec( 1777777777740000000002 ) =
= 1.8446744069415E+19

octdec( 37777777777 ) =
= 4294967295

octdec( 1000000000000000000002 ) =
= 9.2233720368548E+18


octdec( 777777777777777777777 ) =
= 9223372036854775807

octdec( 7.7777777777778E+20 ) =
= 5184372088784


octdec( 998999998 ) =
= 0

octdec( 2732 ) =
= 1498


You must be careful when using this function, especially when handling negative values.