License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6-block.git] / arch / x86 / lib / misc.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
a17bce4d
BP
2/*
3 * Count the digits of @val including a possible sign.
4 *
5 * (Typed on and submitted from hpa's mobile phone.)
6 */
646e29a1
BP
7int num_digits(int val)
8{
a17bce4d
BP
9 int m = 10;
10 int d = 1;
646e29a1 11
a17bce4d
BP
12 if (val < 0) {
13 d++;
14 val = -val;
646e29a1
BP
15 }
16
a17bce4d
BP
17 while (val >= m) {
18 m *= 10;
19 d++;
20 }
21 return d;
646e29a1 22}