• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: doubles not behaving
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: doubles not behaving


  • Subject: Re: doubles not behaving
  • From: Gregory Weston <email@hidden>
  • Date: Sun, 13 Jun 2004 13:13:46 -0400

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.

Happily a quick experiment in Xcode indicates that %lf works quite well.

(and though %Lf is valid, it's not implemented and is equivelant to %f).

Also problematic, but only in the abstract right now since double and long double are the same size with mainstream tools.

G
_______________________________________________
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.


  • Follow-Ups:
    • Re: doubles not behaving
      • From: Prachi Gauriar <email@hidden>
References: 
 >Re: doubles not behaving (From: Gregory Weston <email@hidden>)
 >Re: doubles not behaving (From: Gwynne <email@hidden>)

  • Prev by Date: Re: How can I find out info on running processes
  • Next by Date: Semi-OT: Re: which americans....?
  • Previous by thread: Re: doubles not behaving
  • Next by thread: Re: doubles not behaving
  • Index(es):
    • Date
    • Thread