Home Tutorials Forums Articles Blogs Movies Library Employment Press

 ActionScript.org Forums rounding to 2 decimal places (dollars and cents)
 Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

 09-09-2001, 06:25 PM #1 mperrah Registered User   Join Date: Sep 2001 Posts: 2 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
 09-10-2001, 05:27 AM #2 Jesse ActionScript.org Founder     Join Date: Nov 2000 Location: New York Posts: 8,765 __________________ 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.
 04-24-2008, 05:07 PM #3 ushka Registered User   Join Date: Oct 2007 Location: San Diego Posts: 123 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.
 04-14-2010, 05:08 PM #4 USFbobFL 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; }
 09-11-2011, 05:21 PM #5 uday_sgh Flash-Flex Consultant     Join Date: Nov 2008 Location: Hyderabad, India Posts: 73 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.

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home ActionScript Forums Group     ActionScript 3.0     ActionScript 2.0     ActionScript 1.0 (and below)     Simple Stuff (Newbies) Flash General Questions     Flash 10 General Questions     Flash 9 General Questions     Flash 8 General Questions     Other Flash General Questions Flex     Flex 2, 3 & 4     Flex 1 Extensions and Plugins     Components     JSFL - Extending Flash Desktop, Mobile and non-browser Environments     AIR (Apollo)     FlashLite / Portable Devices Development     Projectors and CDs Supporting Technologies     HTML and JavaScript     haXe     Server-Side Scripting     Flash Remoting     Flash Media Server General     Best Practices     Gaming and Game Development     Animation and Effects     Flashants Support Forum Community Boards     General Chat     Just for Kicks Challenges     Detention Flash In Action     Site Check     Cool Sites     Widgets Decommissioned     Projects and Positions CMS Forums     Announcements Board     Content Postings / Updates     Product Review Requests     CMS Technical Questions     Process Questions     Collaboration & Suggested Articles

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

///