By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,826 Members | 815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,826 IT Pros & Developers. It's quick & easy.

data type for decimal number

P: n/a
which is the best format specifier(data type) if i have to work with
decimal number.

also please tell me the syntax for truncating a decimal number

please reply as soon as possible
Feb 16 '08 #1
Share this Question
Share on Google+
23 Replies


P: n/a
ne**********@yahoo.co.in said:
which is the best format specifier(data type) if i have to work with
decimal number.
There is no such thing as a "decimal number". Numbers are numbers. But
presumably you mean that you wish to display a number using decimal
notation, and your reference to a format specifier suggests that you wish
to do this using printf.

If you have an int type, use %d or %i. For short int and long int, apply
the appropriate modifiers, as listed in your C book (in K&R2 they're on
page 244). For unsigned int types, use %u rather than %d or %i.

If you wish to display a floating point type, use %f.
also please tell me the syntax for truncating a decimal number
This depends on what you mean by "truncate" and on what type of value you
wish to truncate (and particularly on whether you want the stored value to
be truncated, or merely the displayed value).

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Feb 16 '08 #2

P: n/a
On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>There is no such thing as a "decimal number". Numbers are numbers. But
presumably you mean that you wish to display a number using decimal
notation, and your reference to a format specifier suggests that you wish
to do this using printf.
A tiny point. The Standard does use the term "decimal number" in the
section on strftime(). Its meaning is exactly what you wrote about
display, but I would avoid writing that there is no such thing as ....
You know that there is always an exception. ;-)
Feb 17 '08 #3

P: n/a
Robert W Hand said:
On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>>There is no such thing as a "decimal number". Numbers are numbers. But
presumably you mean that you wish to display a number using decimal
notation, and your reference to a format specifier suggests that you wish
to do this using printf.

A tiny point. The Standard does use the term "decimal number" in the
section on strftime(). Its meaning is exactly what you wrote about
display, but I would avoid writing that there is no such thing as ....
You know that there is always an exception. ;-)
The fact that the Standard uses the term "decimal number" does not mean
there is such a thing as a decimal number. It merely means that the people
who wrote that part of the Standard think there is such a thing as a
decimal number.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Feb 18 '08 #4

P: n/a
In article <RO******************************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>Robert W Hand said:
>On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>>>There is no such thing as a "decimal number". Numbers are numbers. But
presumably you mean that you wish to display a number using decimal
notation, and your reference to a format specifier suggests that you wish
to do this using printf.

A tiny point. The Standard does use the term "decimal number" in the
section on strftime(). Its meaning is exactly what you wrote about
display, but I would avoid writing that there is no such thing as ....
You know that there is always an exception. ;-)

The fact that the Standard uses the term "decimal number" does not mean
there is such a thing as a decimal number. It merely means that the people
who wrote that part of the Standard think there is such a thing as a
decimal number.
I will leave it to my esteemed colleague, Mr. Twink, to give this post
all the respect that it deserves.

Feb 18 '08 #5

P: n/a
On 18 Feb 2008 at 3:22, Kenny McCormack wrote:
In article <RO******************************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>>Robert W Hand said:
>>On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:

There is no such thing as a "decimal number". Numbers are numbers. But
presumably you mean that you wish to display a number using decimal
notation, and your reference to a format specifier suggests that you wish
to do this using printf.

A tiny point. The Standard does use the term "decimal number" in the
section on strftime(). Its meaning is exactly what you wrote about
display, but I would avoid writing that there is no such thing as ....
You know that there is always an exception. ;-)

The fact that the Standard uses the term "decimal number" does not mean
there is such a thing as a decimal number. It merely means that the people
who wrote that part of the Standard think there is such a thing as a
decimal number.

I will leave it to my esteemed colleague, Mr. Twink, to give this post
all the respect that it deserves.
It would be nice to say something funny and cutting, but Heathfield's
post is so far off into la-la land that it's beyond the power of parody
to match the absurdity of the post itself... Still, it must be fun in a
way to be Heathfield, completely unconstrained by reality.

Feb 18 '08 #6

P: n/a
On Feb 16, 11:40*pm, neha_chha...@yahoo.co.in wrote:
which is the best format specifier(data type) if i have to work with
decimal number.
The best format specifier for a decimal number depends upon how you
want
to use it. If you want to display a normal signed integer , you can
use "%d"
unsigned integer "%u".

Some times the when you print addresses using %d it will show as
negative,
but we know that addresses cant be negative. So we should use %u as
format
specifier.
As you know numbers can be signed or unsigned and the value
it can hold depends upon the type we use it. Also if you want
large values, you have to use appropriate data types and correspoding
format specifiers according to that. for eg.

int - %d
long - %ld
double - %lf
float - %f
hex -%x.
for the rest you can refer this link

http://publib.boulder.ibm.com/infoce...specifiers.htm


also please tell me the syntax for truncating a decimal number
if you mean to say display after truncating a decimal number,
then you can use the format specifiers used for float.
please reply as soon as possible





Feb 18 '08 #7

P: n/a
Keith Thompson wrote:
... unsigned long is very
often the same size as unsigned long, but it's not guaranteed.
Is this the Schroedinger C compiler we're talking about here?
Feb 18 '08 #8

P: n/a
Keith Thompson said:
Richard Heathfield <rj*@see.sig.invalidwrites:
>vh************@gmail.com said:

<snip>
>>Some times the when you print addresses using %d it will show as
negative,

Don't print addresses using %d. Addresses are pointer values, so use %p.

Use %p *after* converting the value to void*.
Whoops, I forgot to mention that.

<snip>
>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.

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Feb 18 '08 #9

P: n/a
On Mon, 18 Feb 2008 17:22:37 +0000, Richard Heathfield wrote:
Keith Thompson said:
>Richard Heathfield <rj*@see.sig.invalidwrites:
>>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/; [...]
Feb 18 '08 #10

P: n/a
Harald van D?k said:
On Mon, 18 Feb 2008 17:22:37 +0000, Richard Heathfield wrote:
>Keith Thompson said:
>>Richard Heathfield <rj*@see.sig.invalidwrites:
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?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Feb 18 '08 #11

P: n/a
On Feb 18, 11:46 am, Harald van Dk <true...@gmail.comwrote:
On Mon, 18 Feb 2008 17:22:37 +0000, Richard Heathfield wrote:
Keith Thompson said:
Richard Heathfield <r...@see.sig.invalidwrites:
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/; [...]
ANSI/ISO 9899-1990
American National Standard for Programming Languages - C

7.9.6.1 The fprintf function

o, u, , x, X The unsigned int argument...
Feb 18 '08 #12

P: n/a
In article <7J******************************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>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?
My copies of C89 (which are BSI standard BS EN 29899:1993, and the BSI
copy of the ISO draft copied from ANSI distributed in 1989-90 for
comments), both specify unsigned int for o,u,x,X. A 1984 draft has
wording similar to yours.

-- Richard
--
:wq
Feb 18 '08 #13

P: n/a
On Feb 18, 12:22 pm, ymunt...@gmail.com wrote:
On Feb 18, 11:46 am, Harald van Dk <true...@gmail.comwrote:
On Mon, 18 Feb 2008 17:22:37 +0000, Richard Heathfield wrote:
Keith Thompson said:
>Richard Heathfield <r...@see.sig.invalidwrites:
>>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/; [...]

ANSI/ISO 9899-1990
American National Standard for Programming Languages - C

7.9.6.1 The fprintf function

o, u, , x, X The unsigned int argument...
Another interesting thing:
http://www.lysator.liu.se/c/rat/d9.html#4-9-6-1
What the heck?
Feb 18 '08 #14

P: n/a
In article <7J******************************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>Harald van D?k said:
>On Mon, 18 Feb 2008 17:22:37 +0000, Richard Heathfield wrote:
>>Keith Thompson said:
Richard Heathfield <rj*@see.sig.invalidwrites:
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.
--
This is a Usenet signature block. Please do not quote it when replying
to one of my postings.
http://en.wikipedia.org/wiki/Signature_block
Feb 18 '08 #15

P: n/a
On Feb 18, 12:32 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
In article <7J-dnX6UeKWCWiTanZ2dnUVZ8sDin...@bt.com>,
Richard Heathfield <r...@see.sig.invalidwrote:
Harald van D?k said:
On Mon, 18 Feb 2008 17:22:37 +0000, Richard Heathfield wrote:
Keith Thompson said:
Richard Heathfield <r...@see.sig.invalidwrites:
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".
So this means that the ISO standard was actually different from
the ANSI one (because the ISO one has two paragraphs, one for 'i,d',
and another one for 'o,u,x,X')? Is there a list of changes somewhere?

Yevgen
Feb 18 '08 #16

P: n/a
Walter Roberson said:

<snip>
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.
Thank you, Walter. I have amended my C89 draft accordingly (because
otherwise I'll only make the same stupid mistake again!).

And, of course, my apologies to all, for posting misleading information
upthread.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Feb 18 '08 #17

P: n/a
Walter Roberson <ro******@ibd.nrc-cnrc.gc.cawrote:
>
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".
That's interesting, *my* nearly-official copy (what was sent to ANSI for
publication) matches ANSI/ISO C90: the first paragraph is for "d" and
"i" and says "int", the second paragraph is for "o", "u", "x", and "X"
and says "unsigned int". Are you sure you're not misreading it? I
sincerely doubt that ANSI change the camera-ready copy.

-Larry Jones

You know how Einstein got bad grades as a kid? Well MINE are even WORSE!
-- Calvin
Feb 18 '08 #18

P: n/a
Mark Bluemel <ma**********@pobox.comwrites:
Keith Thompson wrote:
>... unsigned long is very
often the same size as unsigned long, but it's not guaranteed.

Is this the Schroedinger C compiler we're talking about here?
Yes and no.

What I meant is that unsigned long is very often the same size as void*.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Feb 19 '08 #19

P: n/a
ro******@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
In article <7J******************************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>>Harald van D?k said:
>>On Mon, 18 Feb 2008 17:22:37 +0000, Richard Heathfield wrote:
Keith Thompson said:
Richard Heathfield <rj*@see.sig.invalidwrites:
>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) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Feb 19 '08 #20

P: n/a
On Feb 18, 6:42*pm, Ben Pfaff <b...@cs.stanford.eduwrote:
This was corrected in the corresponding paragraph of
the C99 rationale: [...]
This is all rather unfortunate. K&R2, Plauger, http://flash-gordon.me.uk/ansi.c.txt
and http://www.lysator.liu.se/c/rat/d9.html#4-9-6-1 all say int is
used for o, u, x, X, yet the definitive resource (ISO/IEC 9899:1990)
says they expect unsigned int, and it's a resource I can't get hold of
- I have to rely on quotes on this Newsgroup.

I have the C99 Standard, but my compiler doesn't support it.

--
Martin
Mar 5 '08 #21

P: n/a
In article <wO*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>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.
Extracting the relevant paragraphs of C89 4.9.6.1, starting from
page 133 of the hardcopy (X3.159-1989)

==== page 133 ====

o An option precision gives the minimum number of digits to appear
for the d, i, o, u, x, and X conversions, the number of digits
to appear after the decimal-point character for e, E, and f
conversions, the maximum number of significant digits for the
g and G conversions, or the maximum number of characters to
be written from a string in s conversion. The precision takes
the form of a period (.) followed either by an asterisk *
(described later) or by an option decimal integer; if only the
period is specified, the precision is taken as zero. If the
precision appears with any other conversion specifier, the
behavior is undefined.

o An optional h specifiing that the following d, i, o, u, x, or X
conversion specifier applies to a short int or unsigned short int
argument (the argument will have been promoted according
to the integral promotions, and its value shall be converted to
short int or unsigned short int before printing); an optional h
specifying that a following n conversion specifier applies to
a pointer to a short in argument; an optional l (ell)
specifying that the following d, i, o, u, x, or X conversion
specifier applies to a long int or unsigned long int argument;
an optional l specifying that a following n conversion specifier
applies to a poiner to a long int argument; or an optional L
specifying that a following e, E, f, g, or G conversion specifier
applies to a long double argument. If an h, l or L appears
with any other conversion specifier, the behavior is undefined.
[...]
The flag characters and their meanings are
[...]
# The result is to be converted to an "alternate form". For o
conversions, it increases the precision to force the first digit
of the result to be a zero. For x (or X) conversion, a
nonzero result with have 0x (or 0X) prefixed to it. For
e, E, f, g, and G conversion, the result will always contain
a decimal-point character, even if no digits follow it.
(Normally, a decimal-point character appears in the result of
these conversions only if a digit follows it.) For g and G
conversions, trailing zeros will not be removed from the
result. For other conversions, the behavior is undefined.

==== page 134 ====
0 For d, i, o, u, x, X, e, E, f, g, and G conversions, leading zeros
(following any indication of sign or base) are used to pad to
the field width; no space padding is performed. If the 0 and -
flags both appear, the 0 flag will be ignored. For d, i, o, u,
x, and X conversions, if a precision is specified, the 0 flag
will be ignored. For other conversions, the behavior is undefined.

The conversion specifiers and their meanings are

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 expanding 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.

c The int argument is converted to an unsigned char, and the
resulting character is written.
====
The text quoted by Richard Heathfield does NOT appear in
C89 4.9.6.1 in the hardcopy version. (I do not know what his source
was.)
--
"When a scientist is ahead of his times, it is often through
misunderstanding of current, rather than intuition of future truth.
In science there is never any error so gross that it won't one day,
from some perspective, appear prophetic." -- Jean Rostand
Mar 5 '08 #22

P: n/a
Walter Roberson said:
In article <wO*********************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>>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.

Extracting the relevant paragraphs of C89 4.9.6.1, starting from
page 133 of the hardcopy (X3.159-1989)
Er, Walter, this is weeks old, if not months.
====
The text quoted by Richard Heathfield does NOT appear in
C89 4.9.6.1 in the hardcopy version.
So I understand.
(I do not know what his source was.)
A draft copy of C89. (I have a "real" C99 Standard, but not C89.)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Mar 5 '08 #23

P: n/a
In article <6d******************************@bt.com>,
Richard Heathfield <rj*@see.sig.invalidwrote:
>Walter Roberson said:
>Extracting the relevant paragraphs of C89 4.9.6.1, starting from
page 133 of the hardcopy (X3.159-1989)
>Er, Walter, this is weeks old, if not months.
February 18th actually. But someone responded today (or last night)
in the thread, and when I went back up the chain I could see there
was still confusion about where exactly the unsigned had appeared,
with the follow-up postings appearing to indicate that the change
appeared in the Rationale for C99, whereas they were in C89 to start with.
So I quoted everything relevant to (hopefully) settle the matter.
--
"The beauties of conception are always superior to those of
expression." -- Walter J. Phillips
Mar 5 '08 #24

This discussion thread is closed

Replies have been disabled for this discussion.