Math::BigInt module in Perl provides objects that represent integers with arbitrary precision and overloaded arithmetical operators.
from_oct() method of Math::BigInt module is used to convert the octal number passed as input to its corresponding decimal number.
Syntax: Math::BigInt->from_oct()
Parameter: input octal number to be converted
Returns: a corresponding decimal number of the passed octal number
Example 1:
perl
#!/usr/bin/perl # Import Math::BigInt module use Math::BigInt;
# Converting from octal to decimal $x = Math::BigInt->from_oct( "0345" );
print ( "$x\n" );
# Converting from octal to decimal $x = Math::BigInt->from_oct( "_443" );
print ( "$x\n" );
|
Output:
229 291
Example 2:
perl
#!/usr/bin/perl # Import Math::BigInt module use Math::BigInt;
# Converting negative number # from octal to decimal $x = Math::BigInt->from_oct( "-0345" );
print ( "$x\n" );
# Converting negative number # from octal to decimal $x = Math::BigInt->from_oct( "-_443" );
print ( "$x\n" );
|
Output:
-229 -291