Can I know how many digits a number is without count it?

我们两清 提交于 2020-01-06 12:41:08

问题


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?


回答1:


If the number is strictly positive, something like: (+ 1 (floor (log10 n))) should do the trick



来源:https://stackoverflow.com/questions/27229987/can-i-know-how-many-digits-a-number-is-without-count-it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!