And don't forget about the %g format specifier, which also trims trailing zeroes automatically. (It also will change from "normal" format to "exponential" format automatically too.)