Linux Audio

Check our new training course

Loading...
v6.8
 1// SPDX-License-Identifier: GPL-2.0
 2#include <asm/misc.h>
 3
 4/*
 5 * Count the digits of @val including a possible sign.
 6 *
 7 * (Typed on and submitted from hpa's mobile phone.)
 8 */
 9int num_digits(int val)
10{
11	long long m = 10;
12	int d = 1;
13
14	if (val < 0) {
15		d++;
16		val = -val;
17	}
18
19	while (val >= m) {
20		m *= 10;
21		d++;
22	}
23	return d;
24}
v6.2
 1// SPDX-License-Identifier: GPL-2.0
 
 
 2/*
 3 * Count the digits of @val including a possible sign.
 4 *
 5 * (Typed on and submitted from hpa's mobile phone.)
 6 */
 7int num_digits(int val)
 8{
 9	int m = 10;
10	int d = 1;
11
12	if (val < 0) {
13		d++;
14		val = -val;
15	}
16
17	while (val >= m) {
18		m *= 10;
19		d++;
20	}
21	return d;
22}