News for hackers. Stuff that matters.
Re:How to Print Integers Really Fast by Const-me on Sunday December 24, 2017 @10:54AM (#16000003)
Your “d = ((uint32_t)n * 53687 + 8208) >> 29;” is no faster than “d = n / 10000;” Modern compilers already apply these multiply-shift tricks when dividing by a constant.
Re:How to Print Integers Really Fast by phkahler on Sunday December 24, 2017 @11:07AM (#16000041)
I was writing for an ARM based micro controller. The compiler may well have been GCC. I should have timed it vs the obvious use of division. I was not aware that they would do such things for division by arbitrary large numbers. If that's all so, then why is TFA worried about the speed of itoa?
Re:How to Print Integers Really Fast by Const-me on Sunday December 24, 2017 @11:40AM (#16000169)
> I was not aware that they would do such things for division by arbitrary large numbers.

They don’t, just 10000 is not large enough :-) But yeah, apparently 32-bit 10k division works on GCC ARM as well: https://godbolt.org/g/ebJqrw

> why is TFA worried about the speed of itoa?

Because itoa is slow.

I once needed to read / write large (100MB+) G-code files. Profiler showed me it spent majority of time in standard library routines like itoa / atof / etc.

Replacing itoa with http://fmtlib.net lead to much faster code.