[rrd-users] How to set values with a beginning Zero?

Alex van den Bogaerdt alex at vandenbogaerdt.nl
Tue Feb 28 13:41:58 CET 2012


>> Hi Chris,
>> but this method would add a leading zero always, right? My problem is,
>> that I don't what to add a leading zero, if the value already has two
>> numbers before the point.
>
> You can specify in the formula how many digits you want to print
> before the decimal point. If you use a format of "%02.2lf" then it
> will print two digits (zero padded) before the decimal point and 2
> digits after the decimal point.

the first answer was correct.
%05.2lf will print at least 5 characters, including the decimal point.
Two characters will be after the point. That leaves at least 2 chars in
front, zero padded if needed.

google man printf will point to useful manuals.




More information about the rrd-users mailing list