Function get_digits(): Return 1 when input number is 0

git-svn-id: https://svn.code.sf.net/p/porg/code/trunk@186 8854956c-c02d-4db9-8198-7e99b8e08f37
This commit is contained in:
davidrr 2017-06-05 06:12:11 +00:00
parent 025430a562
commit f355e83c98
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,9 @@
SVN
---
+ porg: Function get_digits(): Return 1 when input number is 0.
Version 0.10 (17 May 2016)
--------------------------

View File

@ -338,7 +338,7 @@ static int get_digits(ulong n)
{
int ret;
for (ret = 0; n; n /= 10, ret++) ;
return ret;
return max(1, ret);
}