itoa icon indicating copy to clipboard operation
itoa copied to clipboard

Features: zero-padding and fixed-point

Open spannella opened this issue 1 year ago • 2 comments

I wanted to see how hard it might be to extend this to get fixed length zero-padded responses.

The other use-case is slightly less common but it can be often helpful to represent a fixed-point decimal number with a standard integer type like int32_t or int64_t where the number is stored as N * 10^D where D is the number of decimal digits supported. I was trying to think of how one could utilize your same approach but with the added issue of inserting the decimal place and potentially having leading zeros after the decimal but before the first digit.

Finally there is the fixed length, fixed-point decimal number, where you want to render the same number fixed-point decimal number but with a fixed number of decimal places and zero padding in the front for the rest

Mostly just thoughts on how this could be extended, I could provide naïve solutions to each of these if its helpful

spannella avatar Dec 31 '22 04:12 spannella