Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-09-2001, 06:25 PM   #1
Registered User
Join Date: Sep 2001
Posts: 2
Send a message via AIM to mperrah Send a message via Yahoo to mperrah

I am building a shopping cart http://www.mperrah.com/tulip/archive/index.html
(Click the images to get to the cart.)
I multiply the sales tax and get 3 or more decimals places for the result.
Is there a way to round up to 2 decimals
ie ($123.46)
not ($123.456...)
I can send the .fla file to anyone interested
mperrah is offline   Reply With Quote
Old 09-10-2001, 05:27 AM   #2
ActionScript.org Founder
Jesse's Avatar
Join Date: Nov 2000
Location: New York
Posts: 8,765


search = good

Jesse Stratford
ActionScript.org Cofounder

Please don't email or PM me Flash questions, that's what the Forums are for!

Please don't rely on me reading my PMs either. Email me about important stuff.
Jesse is offline   Reply With Quote
Old 04-24-2008, 05:07 PM   #3
Registered User
Join Date: Oct 2007
Location: San Diego
Posts: 123
Lightbulb Math.round to two decimal places


Last edited by ushka; 04-24-2008 at 10:39 PM.
ushka is offline   Reply With Quote
Old 04-14-2010, 05:08 PM   #4
Registered User
Join Date: Apr 2010
Location: Florida
Posts: 1

Here's a nice little function that rounds to any number of decimal places.

private function roundDec(numIn:Number, decimalPlaces:int):Number {
var nExp:int = Math.pow(10,decimalPlaces) ;
var nRetVal:Number = Math.round(numIn * nExp) / nExp
return nRetVal;
USFbobFL is offline   Reply With Quote
Old 09-11-2011, 05:21 PM   #5
Flash-Flex Consultant
uday_sgh's Avatar
Join Date: Nov 2008
Location: Hyderabad, India
Posts: 73
Send a message via MSN to uday_sgh Send a message via Yahoo to uday_sgh Send a message via Skype™ to uday_sgh

Here is very simple code to round up the decimal as below:
ActionScript Code:
var cost = 5.2382565 var roundCost = cost.toFixed(2) trace(roundCost); // Here you will get the output: 5.24
You change the toFixed value as per you need instead of 2.

I hope it will resolve your problem if you have any other issue please let me know.
uday_sgh is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 11:27 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.