Re: sprintf() does not align right
IIRC, the format descriptor is <total # of digits>.<trailing number of digits>
When it comes to *print()ing, the format descriptor is considered a non-binding "wish": you'll get the number of digits required in front of the deci-point plus the number of trailing digits.
For what you seen to see, "%8.2f" might work.
PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)