• 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: Rounding to two decimals
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rounding to two decimals


  • Subject: Re: Rounding to two decimals
  • From: "Ihar 'Philips' Filipau" <email@hidden>
  • Date: Sun, 18 Jul 2004 13:16:27 +0200

Ken Garden wrote:

The text printed in averageLabel is "1.6000000238...". It seems the
rounding is done quite nicely, I'm just wondering why there's such a
strange extension. An idea how I can get rid of this?

Did you tryed using NSString initWithFormat: ?
Last decade I'm working as software developer and last 30 years of Unices, formating were doing right thing.

I'm absolutely sure that NeXT got it right too - I cannot test it fast - i'm not a /visual/ programmer.

[ifilipau@diana ~]$ cat a.c

#include <stdio.h>

int main()
{
float a = 123.159;

printf("%f\n", a);
printf("%.2f\n", a);

return 0;
}

[ifilipau@diana ~]$ ./a
123.158997
123.16
[ifilipau@diana ~]$
_______________________________________________
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.


References: 
 >Rounding to two decimals (From: Ken Garden <email@hidden>)
 >Re: Rounding to two decimals (From: Yann Bizeul <email@hidden>)
 >Re: Rounding to two decimals (From: Ken Garden <email@hidden>)

  • Prev by Date: Get the latest song pathname played by iTunes
  • Next by Date: Making an NSTextView plain text
  • Previous by thread: Re: Rounding to two decimals
  • Next by thread: Rép : NSHost class
  • Index(es):
    • Date
    • Thread