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

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
Jesse
ActionScript.org Founder
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: New York
Posts: 8,736
Default

http://www.actionscripts.org/forums/...aily=&pagenum=

search = good
__________________
Cheers

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
ushka
Registered User
 
Join Date: Oct 2007
Location: San Diego
Posts: 123
Lightbulb Math.round to two decimal places

Math.round(number*100)/100
http://kb.adobe.com/selfservice/view...nalId=tn_15542

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
USFbobFL
Registered User
 
Join Date: Apr 2010
Location: Florida
Posts: 1
Default

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
uday_sgh
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
Default

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
Reply


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 09:32 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, 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.