More than 5 years have passed since last update.
pythonとperlそれぞれでの数値の桁数の数えかた
pythonのやつの考え方は数学的に参考になる
pythonの場合
import math
# data の桁数を取得する
data_size = int (math.log10(data) + 1)
perlの場合
# $x の桁数を取得する
$count = $x =~ tr/0-9/0-9/;
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
