3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

数値の桁数を取得する

Last updated at Posted at 2017-06-10

pythonとperlそれぞれでの数値の桁数の数えかた
pythonのやつの考え方は数学的に参考になる

pythonの場合

import math
# data の桁数を取得する
data_size = int (math.log10(data) + 1)

perlの場合

# $x の桁数を取得する
$count = $x =~ tr/0-9/0-9/;
3
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?