I don't think this is possible within sprintf. All floating point numbers have to have a digit before the decimal point.
The standard for printf family of functions states:
f, F
The double argument is rounded and converted to decimal notation in the style -ddd.ddd, where the number of digits after the decimal-point character is equal to the precision specification. If the precision is missing, it is taken as 6; if the precision is explicitly zero, no decimal-point character appears. If a decimal point appears, at least one digit appears before it.
Not too difficult to do with a quick regex or something, though.
$str =~ s/^0\./\./;
In reply to Re: Can sprintf suppress leading zero for float < 1?
by temporal
in thread Can sprintf suppress leading zero for float < 1?
by RotoValue
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |