Why using powers to ten? isn't the multiplication by powers of two faster (using 2^30=1073741824, which is the
power power of 2 nearest of the largest power of 10 representable as a positive value on signed 32-bit)?
And it may be even faster on small platforms without native 64-bit integer and no barrel-shifter, using 2^24=16777216 (allows various compiler optimizations using only 8-bit, 16-bit or 32-bit only registers without requiring any shifting), the purpose being to absolutely minimize the cycles spent in such debugging calls for instrumenting and profiling apps accurately (sometimes such micro-optimizations don't matter, except for instrumentation and debugging: if you need to count millions of events, every cycle spent in each call matters on the final time to not deviate too much from the non-debug version and better select the hotspots in the non-debug version; if you use it for example to measure the number of OP_CODEs processed in the Lua VM, such hook will be extremely used, and you may want to avoid using some costly processing units like ALUs or barrel-shifters for your debugging code, as these processing units in processors could be delayed in its internal pipelines, causing additional wait cycles; this includes even modern multicore CPUs that have less ALUs than pipelines or cores, e.g. with Intel and AMD "hyperthreading" or when running on some GPUs, even if they have fast ALUs). Using multiple of 8-bits for the shift count can also help by avoiding the compilation of loops with conditional counters, as this can be easily inlined (without generating lot of native code instructions in the processor code cache).
Now on STM32, at least, native 32-bit code will be used, and 64-bit arithmetic processing is limited to just the addition in getcount(), which can be implemented in pure-bit code with 3-4 instructions (and without using a costly call to an external
arithmetic
support
library needed by the C compiler, which will attempt to inline the generated code as much as possible).