Commit 9001628b authored by Mark Fasheh's avatar Mark Fasheh

Add function to count digits in a number

Signed-off-by: 's avatarMark Fasheh <>
parent ccc4fb90
......@@ -156,3 +156,14 @@ void record_end_print(struct elapsed_time *e)
printf("%s took %fs\n", e->name, e->elapsed);
int num_digits(unsigned long long num)
unsigned int digits = 0;
while (num) {
num /= 10;
return digits;
......@@ -49,4 +49,6 @@ struct elapsed_time {
void record_start(struct elapsed_time *e, const char *name);
void record_end_print(struct elapsed_time *e);
int num_digits(unsigned long long num);
#endif /* __UTIL_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment