in reply to Re: Can sprintf suppress leading zero for float < 1?
in thread Can sprintf suppress leading zero for float < 1?
If a decimal point appears, at least one digit appears before it.
Thanks for highlighting that! I must have glazed over that sentence in the man pages.
So unfortunately sprintf can't do what I want. I'd like it to support a different conversion specifier that behaved like f, except would omit the leading zero.
Not too difficult to do with a quick regex or something, though.
I agree - my issue isn't so much stripping off the leading zero, but finding the places in my code where I'm currently calling sprintf and replace them with a new wrapper which does it.
Thanks to all for the suggestions.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Can sprintf suppress leading zero for float < 1?
by roboticus (Chancellor) on Apr 14, 2012 at 12:11 UTC | |
by ikegami (Patriarch) on Apr 15, 2012 at 00:34 UTC | |
by roboticus (Chancellor) on Apr 16, 2012 at 14:02 UTC |