On Sun Mar 3 12:57:49 EST 2013, paul-a.patie...@polymtl.ca wrote: > I would also like it if %g acted the same in plan9 > as everywhere else (printing 0.1 instead of .1 in > my example). That's also really easy to change. > > It doesn't make sense for plan9port's %g to be > different from plan9, because now you cannot even > count on both prints to work the same way. Since > printf's %g works like plan9port right now, it > would make sense to change plan9's version. > > I don't know the history behind %g's current > behaviour, however.
i don't have access to 3e sources, but 2e does not add the extra digit like current plan 9 source does. (it does however omit the leading 0 on 0.1.) looking at the differences, i think there's a clue in the 2e comments /* * n is number of digits to convert * 1 before, f2 after, 1 extra for rounding */ we can see that after the label "found:" c1 is set to prec+1, but that's including the rounding digit. (cf. "try decimal rounding" above.) it looks like a simple error in converting the code from the old non-va_args style to the current style. - erik p.s. i haven't talked to anyone to wrote the code, so maybe somebody who knows more about this than i could chime in?