Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Perl 中有一个非常大的数字。我使用“bignum”。如何从这个大数字中提取单个数字。例如,如果我有一个这样的数字,以及从末尾得到第三个数字的内容:
1029384710985234058763045203948520945862986209845729034856 -> 8
1029384710985234058763045203948520945862986209845729034856
-> 8
bignums 是透明可用的,所以这将起作用:
$digit = substr($bignum, -3, 1);
该bignum包Math::BigInt在引擎盖下使用整数。
bignum
Math::BigInt
从Math::BigInt手册页:
$x->digit($n); # return the nth digit, counting from right
请注意,最右边的数字从 0 开始计数。