我可以知道一个数字有多少位数而不算数? [英] Can I know how many digits a number is without count it?
本文介绍了我可以知道一个数字有多少位数而不算数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我想知道大数字的数字时,我会这样做:
user> (count(str(factorial-bigint-loop 32)))
36
一个更好的办法?
如果数字是严格的正数,像: (+ 1(floor(log10 n)))
应该做的
When I want to know how many digits of a big number, I'd do this:
user> (count (str (factorial-bigint-loop 32)))
36
Is there a better way? Can I represent the number in scientific notation?
解决方案
If the number is strictly positive, something like: (+ 1 (floor (log10 n)))
should do the trick
这篇关于我可以知道一个数字有多少位数而不算数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文