Excellent suggestion. Didn't think about splitting into an array. Good idea.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Olson Sent: Wednesday, December 06, 2006 3:48 PM To: [email protected] Subject: [Flashcoders] Re: Flashcoders Digest, Vol 23, Issue 13 Another way to tackle it as well is to split it and compare the 2nd element of the split array. var num:Number = 2.3; var split:Array = String(num).split("."); trace(3 == split[1]); On 12/6/06, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote: > > Message: 21 > Date: Wed, 6 Dec 2006 12:22:43 -0800 > From: "T. Michael Keesey" <[EMAIL PROTECTED]> > Subject: Re: [Flashcoders] Compare Decimal Point Value? > To: "Flashcoders mailing list" <[email protected]> > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=UTF-8; format=flowed > > In Flash 9, I get this for the traces: > 2.3 > 0.2999999999999998 > 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.00001); // true > > On 12/6/06, Doug Coning <[EMAIL PROTECTED]> wrote: > > I'm scratching my head over this. Not sure what I'm doing wrong? I > > need to compare a decimal value of a numeric field to see if it contains > > a specific value of 0.3. Here is some sample code: > > > > var num:Number = 2.3; > > var num2:Number = num - int(num); > > var num3:Number = 0.3; > > > > trace(num); // 2.3 > > trace(num2); // 0.3 > > trace(num3); // 0.3 > > trace(num2 == num3);// false > > trace(num2 > num3);// false > > trace(num2 < num3);// true > > > > Why doesn't 0.3 equal 0.3? I've replaced int with Math.floor(), and it > > still doesn't work. I need to get the value after the decimal point and > > see if it equals 0.3. > > > > Thanks for your help. > > > > Doug Coning > > Senior Web Development Programmer > > FORUM Solutions > > [EMAIL PROTECTED] > _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com This e-mail and any attachment(s) are intended for the specified recipient(s) only and are legally protected. If you have received this communication in error, please "reply to" sender's e-mail address with notification of the error and then destroy this message in all electronic and physical forms. _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com

