2 ms·
This is a fun optimization, but what is a use case where I would need to count the number of digits?
by jedberg 5y ago
This is a fun optimization, but what is a use case where I would need to count the number of digits?
- chrisseaton 5y agoFormatting numbers into strings is a pretty fundamental operation to need to do in your fast-path. For example formatting time into log lines. To do that we need to know how many digits the milliseconds component has so we can pad it with zeros correctly. That's what motivated this particular question in our case.
- jedberg 5y agoThat makes sense. Never really thought about that as a counting digits problem but yeah.