In Flash 9, I get this for the traces:
2.3
0.2998
0.3
false
false
true
Good old-fashioned floating point precision error. Instead of testing
if they are equal, You could test if the difference between them is
very small, e.g.:
trace(Math.abs(num2 - num3) 0.1); // true
On
Of T.
Michael Keesey
Sent: Wednesday, December 06, 2006 3:23 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Compare Decimal Point Value?
In Flash 9, I get this for the traces:
2.3
0.2998
0.3
false
false
true
Good old-fashioned floating point precision error. Instead
Have you tried casting them as Strings and comparing those?
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of T. Michael Keesey
Sent: Wednesday, December 06, 2006 12:23 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Compare Decimal
Math.round(myNum * 10);
:)
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Doug Coning
Sent: Wednesday, December 06, 2006 12:32 PM
To: Flashcoders mailing list
Subject: RE: [Flashcoders] Compare Decimal Point Value?
Is there a better way
: [Flashcoders] Compare Decimal Point Value?
Math.round(myNum * 10);
:)
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Doug Coning
Sent: Wednesday, December 06, 2006 12:32 PM
To: Flashcoders mailing list
Subject: RE: [Flashcoders] Compare
: [Flashcoders] Compare Decimal Point Value?
In Flash 9, I get this for the traces:
2.3
0.2998
0.3
false
false
true
Good old-fashioned floating point precision error. Instead of testing
if they are equal, You could test if the difference between them is
very small, e.g.:
trace(Math.abs
.
Michael Keesey
Sent: Wednesday, December 06, 2006 3:23 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Compare Decimal Point Value?
In Flash 9, I get this for the traces:
2.3
0.2998
0.3
false
false
true
Good old-fashioned floating point precision error. Instead
7 matches
Mail list logo