Re: Cocoa-dev Digest, Vol 3, Issue 385
Re: Cocoa-dev Digest, Vol 3, Issue 385
- Subject: Re: Cocoa-dev Digest, Vol 3, Issue 385
- From: Andrew Farmer <email@hidden>
- Date: Mon, 27 Mar 2006 17:25:01 -0800
On 24 Mar 06, at 23:00, Axman wrote:
Hi all, i'm a 'noob' so if what i have to say is stupid i'm really
sorry. i've only just started programming in cocoa in the last few
days, but i am almost finished a little calculator (yay :D ) but i'm
having an annoying problem when i'm trying to use decimal numbers, i'm
using a variable that is a double (i want my little calc to be pretty
accurate, well very) and after the "." button is pressed i have it so
that this variable (which started out as 1.0) is divided by 10 and
then the number that's pressed is added to the full number that's
being worked on times (*) this variable: here's a little look:
("//debug!" is where i'm trying to find out what value
AXdecimal is)
<etc, etc>
from what i can figure out, i'm not doing anything wrong, but when i
debug it, AXdecimal is "0.10000000000000001", whis is not 1 divided by
10 is it? the result is that i end up with
123.5599975585938 when it should be 123.56. any ideas?
Normal behavior for a floating-point variable. If you need exact
decimals,
take a look at NSDecimalNumber.
Attachment:
PGP.sig
Description: This is a digitally signed message part
_______________________________________________
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