Re: doubles not behaving
Re: doubles not behaving
- Subject: Re: doubles not behaving
- From: Prachi Gauriar <email@hidden>
- Date: Sun, 13 Jun 2004 12:42:07 -0500
On Jun 13, 2004, at 12:13 PM, Gregory Weston wrote:
On Jun 13, 2004, at 12:11 PM, Gwynne wrote:
On Jun 13, 2004, at 11:25 AM, Gregory Weston wrote:
Ok, maybe i am missing something here but why does
this not output the same thing as the input?
double num = [serial doubleValue];
NSLog(@"Serial = %d", num);
%d is the format specifier for ints and long ints. %f is for floats
and
doubles.
%f is for floats.
%lf is for doubles.
No. %f and %F are for doubles. %lf is invalid
That had better not be the case. From ISO 9899:1999:
l (ell) Specifies that a following d, i, o, u, x, X, or n
conversion specifier applies
to an argument with type pointer to long int or unsigned
long int; that a
following a, A, e, E, f, F, g, or G conversion specifier
applies to an argument
with type pointer to double; or that a following c, s, or
[ conversion specifier
applies to an argument with type pointer to wchar_t.
The section you specified is from scanf. The thing that should tip you
off is the word pointer used throughout. For printf, the section says
the following:
l(ell)
Specifies that a following d, i, o, u, x,or X conversion specifier
applies to a long int or unsigned long int argument; that a following n
conversion specifier applies to a pointer to a long int argument; that
a following c conversion specifier applies to a wint_t argument; that a
following s conversion specifier applies to a pointer to a wchar_t
argument; or has no effect on a following a, A, e, E, f, F, g, or G
conversion specifier.
Indeed I thought I remembered as you did Gregory, but I was remembering
scanf, not printf.
-Prachi
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.