RE: [Flashcoders] Re: Flashcoders Digest, Vol 23, Issue 13

2006-12-06 Thread Doug Coning
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: flashcoders@chattyfig.figleaf.com
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 flashcoders@chattyfig.figleaf.com
 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.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 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]

___
Flashcoders@chattyfig.figleaf.com
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.
___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] Re: Flashcoders Digest, Vol 23, Issue 13

2006-12-06 Thread Steven Sacks | BLITZ
Yup, there are all kinds of things you can do if you cast it as a
String.

As far as the rounding thing goes, you want it to round.

0.2999 is supposed to be 0.3

If you multiply 0.29 by 10, you get 2.9.

You round it you get 3.

You divide by 10 you get .3.

myNum = Math.round(myNum * 10) / 10;

That should work and get rid of trailing 9s.

-Steven
___
Flashcoders@chattyfig.figleaf.com
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