in reply to Re^3: Can sprintf suppress leading zero for float < 1?
in thread Can sprintf suppress leading zero for float < 1?

It's safer to place the modifier before the final letter (e.g. %.3Zf) or to pick a different letter (e.g. %.3F). That way, it doesn't restrict the strings into which the pattern can be placed.

I wonder what C# does.

Replies are listed 'Best First'.
Re^5: Can sprintf suppress leading zero for float < 1?
by roboticus (Chancellor) on Apr 16, 2012 at 14:02 UTC

    ikegami:

    Yeah, if I were going to preprocess the string, I would do it that way. But I opted to postprocess it instead. Since I rarely have a numeric field immediately adjacent to an alpha field, it didn't seem like much of a restriction. Also, I thought that preprocessing the string and argument list might get a bit messy if there were many field definitions.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.