float specifier maxes out at 20.
e.g.
> require("sprintf").sprintf("%.99f", 1)
RangeError: toFixed() digits argument must be between 0 and 20
at Number.toFixed (<anonymous>)
at str_format.format (./node_modules/sprintf/lib/sprintf.js:170:49)
Yes
Even in C89 sprintf has no such limitation (well it did have max 99).
If you don't want to implement it, then it at least needs a warning in the docs.
This is a JS implementation and works inside JS limits so I don't think this is warranted.
As a side note, if one's using JavaScript and is bloody serious about the number of digits after the decimal point and finds that 20 digits are insufficient, they're probably using some decimal type. Since this particular implementation has no support for custom types or custom formatting methods, they're probably not using this library either. That, or they print it out as a string and be done with it.
Otoh what might work would be to do away with the type casting. Then one might be able to implement their own toFixed, toPrecision etc. methods on their own special "types".
That would also mean users would have to pass arguments with the appropriate types (i.e. pass float when they mean float etc)
Even though the chance of having someone complain the next day about me breaking their app is pretty high, ~that's~ that change (dropping type casting) is something I'd think about and probably agree with 😊
Opinions?
I updated my previous comment to make it clear that I'd probably agree with forcing users to pass arguments with the appropriate type.
The issue I have is that I'm sharing sprintf strings between a C and a JS codebase: %.99f works in C, but not in JS.