Re: inconsistent float behaviour

2008-10-11 Thread Steven Hamilton
Thanks guys, I'm still unsure why I'm getting 4 decimal places as I know for fact that the data is 2 decimal places. However, it seems my approach is wrong. I'll convert to int's and NSDecimalNumbers instead and remove all floats. On 11/10/2008, at 4:14 AM, Uli Kusterer wrote: On 10.10.2

Re: inconsistent float behaviour

2008-10-11 Thread Steven Hamilton
On 11/10/2008, at 11:59 AM, Kyle Sluder wrote: On Fri, Oct 10, 2008 at 9:58 PM, Kyle Sluder <[EMAIL PROTECTED]> wrote: This article It would help if I provided the link. http://www.setfiremedia.com/blog/7-top-tips-for-coding-with-currency Thanks Kyle. I didn't realise floating point were s

Re: inconsistent float behaviour

2008-10-10 Thread Clark Cox
On Fri, Oct 10, 2008 at 6:33 PM, Steven Hamilton <[EMAIL PROTECTED]> wrote: > Thanks guys, > I'm still unsure why I'm getting 4 decimal places as I know for fact that > the data is 2 decimal places. That is because floating point numbers don't have "decimal places"; forget all about decimal places

Re: inconsistent float behaviour

2008-10-10 Thread Kyle Sluder
On Fri, Oct 10, 2008 at 9:58 PM, Kyle Sluder <[EMAIL PROTECTED]> wrote: > This article It would help if I provided the link. http://www.setfiremedia.com/blog/7-top-tips-for-coding-with-currency ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Ple

Re: inconsistent float behaviour

2008-10-10 Thread Kyle Sluder
On Fri, Oct 10, 2008 at 9:33 PM, Steven Hamilton <[EMAIL PROTECTED]> wrote: > I'm still unsure why I'm getting 4 decimal places as I know for fact that > the data is 2 decimal places. However, it seems my approach is wrong. I'll > convert to int's and NSDecimalNumbers instead and remove all floats.

Re: inconsistent float behaviour

2008-10-10 Thread Steven Hamilton
Thanks guys, I'm still unsure why I'm getting 4 decimal places as I know for fact that the data is 2 decimal places. However, it seems my approach is wrong. I'll convert to int's and NSDecimalNumbers instead and remove all floats. On 11/10/2008, at 4:14 AM, Uli Kusterer wrote: On 10.10.2

Re: inconsistent float behaviour

2008-10-10 Thread Uli Kusterer
On 10.10.2008, at 13:04, Steven Hamilton wrote: NSLog(@"current balance is: %@",balance); and get current balance is: 18976.69 in the console. So far so good. (...) The float calculation is exactly 2 decimal places, I know that for a fact and NSLog proves it. You may want to be aware tha

Re: inconsistent float behaviour

2008-10-10 Thread ghe
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Nick Zitzmann wrote: > > On Oct 10, 2008, at 5:04 AM, Steven Hamilton wrote: > >> Am I totally misunderstanding something about floats? Or is the extra >> ##'s in the formatter making things up? > > > Floating point values of either float or double

Re: inconsistent float behaviour

2008-10-10 Thread Michael Ash
On Fri, Oct 10, 2008 at 7:04 AM, Steven Hamilton <[EMAIL PROTECTED]> wrote: > The float calculation is exactly 2 > decimal places This is unlikely. There are very few numbers with two decimal places which can be perfectly represented in floating-point numbers. (Those would be numbers with fraction

Re: inconsistent float behaviour

2008-10-10 Thread Gary L. Wade
I've not used it myself, but there is also NSDecimal that may be an alternative. Also, I recall seeing an IBM-released class that I believe had been part of ICU that also did decimal arithmetic using 32 or 64 bits. > >On Oct 10, 2008, at 5:04 AM, Steven Hamilton wrote: > >> Am I totally misunde

Re: inconsistent float behaviour

2008-10-10 Thread Nick Zitzmann
On Oct 10, 2008, at 5:04 AM, Steven Hamilton wrote: Am I totally misunderstanding something about floats? Or is the extra ##'s in the formatter making things up? Floating point values of either float or double are not guaranteed to be super precise, and should never be used to represent c

Re: inconsistent float behaviour

2008-10-10 Thread Dave Carrigan
On Oct 10, 2008, at 4:04 AM, Steven Hamilton wrote: Hi folks, I think I need some help understanding floats. I have a class that calculates a balance and places it in a table column. At the end of this method I NSLog the output like so; NSLog(@"current balance is: %@",balance); and get c

inconsistent float behaviour

2008-10-10 Thread Steven Hamilton
Hi folks, I think I need some help understanding floats. I have a class that calculates a balance and places it in a table column. At the end of this method I NSLog the output like so; NSLog(@"current balance is: %@",balance); and get current balance is: 18976.69 in the console. So far so