珀尔 | Math::BigInt->from_oct() 方法
Perl 中的Math::BigInt模块提供了表示具有任意精度和重载算术运算运算符的整数的对象。
Math::BigInt模块的from_oct()方法用于将作为输入传递的八进制数转换为其对应的十进制数。
Syntax: Math::BigInt->from_oct()
Parameter: input octal number to be converted
Returns: a corresponding decimal number of the passed octal number
示例 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");
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");
输出:
229
291
示例 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");
输出:
-229
-291