如何设置Perl的bignum的精度水平?

the*_*ear 9 precision perl bignum

我正在尝试在Perl中使用bignum模块并想要设置精度.我知道这可以通过一个内衬来完成,详见模块的CPAN页面:

$ perl -Mbignum=p,-50 -le 'print sqrt(20)'
Run Code Online (Sandbox Code Playgroud)

...它将打印出20到50位精度的平方根,但我想知道的是,无论如何都要在脚本中设置精度,例如:

#!/usr/bin/perl
use bignum;

setPrecision(-50);
print sqrt(20);
Run Code Online (Sandbox Code Playgroud)

到目前为止,我在这里,Google和PerlMonks都没有运气.提前致谢.

mar*_*ton 12

Per Anon.的建议:

#!/usr/bin/perl

use strict;
use warnings;

use bignum ( p => -50 );

print sqrt(20);
Run Code Online (Sandbox Code Playgroud)

您可能希望查看bignum使用的Math :: BigFloatMath :: BigInt的文档.