(SOC) Storage Only Commit
(ADD) Name, NameScope, Catlog, Object, String, Attribute, Char, Registry, Utils, Type, <Platform Support>, <Global Constants>, README (MOD) Array, Var, Status, MemMan, <Common>
This commit is contained in:
9
Utils/include/utils.h
Normal file
9
Utils/include/utils.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef COMPOUND_UTILS_H
|
||||
# define COMPOUND_UTILS_H
|
||||
|
||||
# include <Compound/common.h>
|
||||
# include <Compound/const.h>
|
||||
|
||||
int Utils_CalcDigits(long long n);
|
||||
|
||||
#endif /* COMPOUND_UTILS_H */
|
16
Utils/src/utils.c
Normal file
16
Utils/src/utils.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <Compound/utils.h>
|
||||
|
||||
int Utils_CalcDigits(long long n)
|
||||
{
|
||||
if (n == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
n = llabs(n);
|
||||
|
||||
/* Accumulate. */
|
||||
register int i;
|
||||
for (i = 0; n; i++) n /= 10;
|
||||
|
||||
return i;
|
||||
}
|
Reference in New Issue
Block a user