This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

possible printf error


First, I am on a system which I believe uses an earlier version of newlibc. I've
encountered an oddity which may?? be an issue.
The use of "printf("%#.6x", 0);" produces "000000". Which, by the IEEE definition of
the '#' flag states: "For x or X conversion specifiers, a non-zero result shall have
0x (or 0X) prefixed to it.", is correct. However, in a series of hex(s) with a variable
input rather than an explicit "0", if one is expecting to have an implicit field width
of 8, ie 0x000030, 0x000100, 0x000000...., or a hex with a 0x prefix when "0" occurs,
you have to test for 0 and issue "printf("%s", "0x");""printf("%#.6x", 0);".
I may have missed the point of a '#' flag, but I thought this incorrect in spite of the
definition. I can see where "printf("%#.0x", 0);" should drop "0x" but why "%#x"?


  Well, food for thought.
Thanks,
     Steve @<tauvan@starpower.net>

PS. Have a couple of others, and would like to know if there is a discussion bb address
to query, rather than this bug reporting address?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]