• 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: decimal floating formatting question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: decimal floating formatting question


  • Subject: Re: decimal floating formatting question
  • From: Jonathan Jackel <email@hidden>
  • Date: Wed, 22 Dec 2004 22:02:32 -0500

Try %g. According to man printf, "The argument is printed in style f or in style e (E) whichever gives full precision in minimum space." It's not exactly what you want, but close. JJ.

On Dec 22, 2004, at 6:59 PM, Mark Dawson wrote:

Is there a way to format a decimal number with no trailing zeros and show only "X" number of digits? I would like 1.0 to show up as "1", 1.2 as '1.2";, 1.31457 as "1.3146".

I'm familiar with the "%.4f" type format, but while this limits the output to 4 decimal points, it adds trailing zeros (i.e., "1.2000"). Is there a way to the best of both worlds via a formatting option?

Thanks!

mark

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >decimal floating formatting question (From: Mark Dawson <email@hidden>)

  • Prev by Date: Re: decimal floating formatting question
  • Next by Date: More authorization woes, the methods giving me trouble
  • Previous by thread: Re: decimal floating formatting question
  • Next by thread: Re: decimal floating formatting question
  • Index(es):
    • Date
    • Thread