473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Actionscript Math Round

5
hi all, i hav a problem in generatin script for rounded amount of decimal in flash
e.g. if amount is Rs.25.68 den i want to display in round figur as Rs.26.00 so how i can do ? plz answer me soon..

thnks & regards
Kraj
Aug 8 '07 #1
3 8054
kestrel
1,071 Expert 1GB
To accomplish that, you would use math.round
Heres a brief explanation with examples.
The Math.round() method is used to round a number up or down to the nearest integer. Positive numbers with a decimal point less than 0.5, and negative numbers with a decimal point greater than 0.5 are rounded down. Postivie numbers with a decimal point greater than or equal to 0.5, and negative numbers with a decimal point less than or equal to 0.5 are round up.

Example:
Math.round(1.499999); // Returns 1
Math.round(1.5); // Returns 2
Math.round(1.6); // Returns 2
Math.round(-5.49999); // Returns -5
Math.round(-5.5); // Returns -5
Math.round(-5.6); // Returns -6
Aug 8 '07 #2
kestrel
1,071 Expert 1GB
I edited your thread title to one that is more appropriate. Thank you.
Aug 8 '07 #3
chunk1978
224 100+
how is it possible to format a number for a dynamic textbox to always display at 2 decimal points using Actionscript 2.0.

for this code, the dynamic text box is 2 levels deep (or whatever) as you can tell by the path...

Expand|Select|Wrap|Line Numbers
  1. var decimals = _root.DisplayMC.Display = 9;
  2. decimals.toFixed(2);
  3.  
yeah, and my code totally doesn't work at all...

any thoughts?
Feb 23 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Nicolas | last post by:
Why does for the same code I got different result the VB code gave me what I want why not the csharp? Thank you for your help... CSHARP CODE int sx, sy; double sdegrees; sdegrees = (90 -...
6
by: ng_mr | last post by:
No, not a question about "banker's rounding" or whatever it's called. I want to round a double to the nearest 100th, so I perform the following: // original is a double double result =...
1
by: nvphu | last post by:
I need to use the constant M_PI. So, I insert the directive # include <math.h>. However when compiled, there are errors : M_PI undeclared identifier. Second, I can not use the function...
6
by: Mitchell Vincent | last post by:
Just making sure I'm not missing the boat here, but are there any special routines for doing currency math (fixed precision stuff) in .NET? The wonderful problems of doing math on decimals tend...
4
by: Chris Davoli | last post by:
The folllowing will round to 526, but it should round to 527. It works correctly for all other numbers, except for this one. Does anybody know of a bug in Math.Round? Dim ldecWater As Decimal =...
10
by: David Coleman | last post by:
I am running VS 2003 and have applied SP1. (On WinXP SP2, .Net 1.1) In the Command Window I get the following ? Math.Round(0.715, 2) 0.72 ? Math.Round(0.725, 2) 0.72 ? Math.Round(0.735, 2)...
6
by: Zeng | last post by:
Math.Round has good behavior as following: Math.Round(3.45, 1); //Returns 3.4. The last '5' is thrown away because 4 is even Math.Round(3.75, 1); //Returns 3.8. The last '5' is used because '7'...
4
by: =?Utf-8?B?UmVuZQ==?= | last post by:
Hello everyone I have a problem with Math.Round, it´s ocurring some strange: Math.Round(12.985) = 12.98, it´s wrong. It should be: 12.99 Why?? What is the problem? Help ME !!!!
1
by: richy1981 | last post by:
Hi i have Flash CS3 and i'm having a nightmare. done a tutorial here http://www.oman3d.com/tutorials/flash/video/preloader.php seemed to be ok till i tried it and got two errors heres the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.