• 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: Gwynne <email@hidden>
  • Date: Sun, 13 Jun 2004 12:11:24 -0400

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 (and though %Lf is valid, it's not implemented and is equivelant to %f). There is no difference between %f and %F; %f is the preferred form. There is no specifier reserved for floats specifically; use %f for both floats and doubles.

From the printf(3) manpage:

fF The double argument is rounded and converted to decimal notation
in the style [-]ddd.ddd, where the number of digits after the
decimal-point character is equal to the precision specification.

-- Gwynne, key to the Code that runs us all
Formerly known as Sailor Quasar.
Email: email@hidden
Web: http://musicimage.plasticchicken.com/
_______________________________________________
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: Gregory Weston <email@hidden>
References: 
 >Re: doubles not behaving (From: Gregory Weston <email@hidden>)

  • Prev by Date: How can I find out info on running processes
  • Next by Date: You know you're over-caching IMPs when..
  • Previous by thread: Re: doubles not behaving
  • Next by thread: Re: doubles not behaving
  • Index(es):
    • Date
    • Thread