> > during developing a new shell script; I detected an erroneous behaviour > > of the printf command. > > printf fails on hex conversion for 008 and 009 and gives wrong values > > for higher numbers, if the digit to convert contains leading zeroes. > > Without leading zeroes the conversion succeeds. > > I'm guessing that 'printf' is interpretting the number as an octal number, > because of the leading zeroes. I can't seem to find anything in 'man printf' > or 'info printf' to confirm this, though (DJGPP port of sh-utils 2.0.11).
I did not see it documented in the 'info printf' documentation either. But the standards require it. http://www.unix-systems.org/single_unix_specification_v2/xcu/printf.html Note that the value shown on standard output is what would be expected as the return value from the XSH specification function strtol(). A similar correspondence exists between %u and strtoul() and %e, %f and %g (if the implementation supports floating-point conversions) and %strtod(). And tracing through to the strtoul() docs: http://www.unix-systems.org/single_unix_specification_v2/xsh/strtol.html If the value of base is 0, the expected form of the subject sequence is that of a decimal constant, octal constant or hexadecimal constant, any of which may be preceded by a + or - sign. A decimal constant begins with a non-zero digit, and consists of a sequence of decimal digits. An octal constant consists of the prefix 0 optionally followed by a sequence of the digits 0 to 7 only. A hexadecimal constant consists of the prefix 0x or 0X followed by a sequence of the decimal digits and letters a (or A) to f (or F) with values 10 to 15 respectively. Bob _______________________________________________ Bug-sh-utils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-sh-utils
