http://www.velocityreviews.com/forums/(E-Mail Removed)-cnrc.gc.ca (Walter Roberson) writes:

> In article <(E-Mail Removed)>,

> Richard Heathfield <(E-Mail Removed)> wrote:

>>Harald van D?k said:

>

>>> On Mon, 18 Feb 2008 17:22:37 +0000, Richard Heathfield wrote:

>>>> Keith Thompson said:

>>>>> Richard Heathfield <(E-Mail Removed)> writes:

>>>>>> Actually, %x takes an int, not a hex. C doesn't have a hex type.

>

>>>>> Actually, %x takes an unsigned int.

>

>>>> 4.9.6.1 of C89:

>

>>>> d, i, o, u, x, X The int argument is converted to signed decimal ( d

>>>> or i ), unsigned octal ( o ), unsigned decimal ( u ), or unsigned

>>>> hexadecimal notation ( x or X );

>

>>>> Sure looks like int to me.

>

>>> Interesting. C99 7.19.6.1p8:

>

>>> o,u,x,X The _unsigned int_ argument is converted to unsigned octal (o),

>>> unsigned decimal (u), or unsigned hexadecimal notation (x or X)

>>> in the style /dddd/; [...]

>

>>Hmmm. Okay, so that's (perhaps) Yet Another Difference between C89 and C99

>>- and a potentially significant one, since it causes difficulty for those

>>wishing to program in the common subset of the two languages. I say

>>"perhaps" because my source doc for C89 is (pace, C.H.!) a mere draft, and

>>as such is suspect in cases like this. Does anyone have a kosher copy of

>>the "real" C89 in which they could check this out?

>

> I have the official ANSI C89 hard-copy publication. It describes

> the integer formats in two related paragraphs, the first of which

> is a summary for all of the formats and uses "int", and the second

> of which is specific to o,u,x,X and uses "unsigned int".

>

> I consider the second of the paragraphs to be a refinement of the first,

> with the first giving the overview and the second the specifics. Thus

> I see no contradiction between versions: as far as I am concerned, both

> C89 and C99 specify that %x and %X require unsigned int.
I have the official ISO C90 PDF publication. Here's what it says:

d,i The int argument is converted to signed decimal in the style

(-]dddd. The precision specifies the minimum number of digits

to appear, if the value being converted can be represented in

fewer digits, it will be expanded with leading zeros. The

default precision is 1. The result of converting a zero value

with a precision of zero is no characters.

o,u,x,X The unsigned int argument is converted to unsigned octal (o),

unsigned decimal (u), or unsigned hexadecimal notation (x or

X) in the style dddd, the letters abcdef are used for x

conversion and the letters ABCDEF for X conversion. The

precision specifies the minimum number of digits to appear; if

the value being converted can be represented in fewer digits,

it will be expanded with leading zeros. The default precision

is 1. The result of converting a zero value with a precision

of zero is no characters.

(It's not a good PDF copy; there may be typos in the above.)

Does that not match the ANSI C89 standard?

--

Keith Thompson (The_Other_Keith) <(E-Mail Removed)>

Nokia

"We must do something. This is something. Therefore, we must do this."

-- Antony Jay and Jonathan Lynn, "Yes Minister"