Uh, isn't Math.floor supposed to round down? [and Math.ceil() rounds up?]
If so, it's working as advertised here.

Scott

On 10/19/06, Martin Tremblay <[EMAIL PROTECTED]> wrote:


I'm wandering if we should continue to use Math.floor() and Math.ceil()
since they are unreliable.

Code:
var a = 2.999999999999999;

trace(parseInt(a.toString()));
trace(Math.floor(a));
trace(a);

output:
3
2
3

Would using methods using parseInt to simulate Math.floor() and
Math.ceil() be safer?

Example

public static function floor(_nValue:Number):Number
{
        return parseInt(_nValue.toString());
}

public static function ceil(_nValue:Number):Number
{
        return parseInt(_nValue.toString()) + 1;
}


Martin T.
lvl

_______________________________________________
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




--

: : ) Scott
_______________________________________________
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

Reply via email to