decoct():octal equivalent of decimal number
<?Php
echo decoct(5); // Output 5
echo "<br>";
echo decoct(55); // Output 67
echo "<br>";
echo decoct(500); // Output is 764
echo "<br>";
echo decoct(658); // Output is 1222
echo "<br>";
echo decoct(3000); // Output is 5670
?>
Syntax
string decoct(int $number);
Parameter | DESCRIPTION |
$number | Required : Decimal number as Input to convert to equivalent octal base number. |
The output is string converted to octal base system.
Example: Convert Hexadecimal to Octal
$hex_value = 'A1';
$decimal_value = hexdec($hex_value);
echo decoct($decimal_value); // Output: 241
Example: Handling Large Numbers
$large_number = 123456789;
echo decoct($large_number); // Output: 726746425
Example: Convert Binary to Octal
$binary_value = '1101';
$decimal_value = bindec($binary_value);
echo decoct($decimal_value); // Output: 15
Example: Octal Conversion for Negative Numbers
$negative_value = -100;
echo decoct($negative_value); // Output: 37777777634 (negative numbers in octal)
Example: Working with Octal and Strings
$number = '123';
$decimal_value = (int)$number;
echo decoct($decimal_value); // Output: 173 (string treated as integer)
← Math Functions
base_convert(): Convert number From any base to other →
decbin() Binary equivalent of decimal number →
dechex(): Convert decimal number to hexadecimal system →
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com