Solved

How to set floating point for number

Posted on 2004-04-25
2
169 Views
Last Modified: 2010-04-03
how i can set the floating point for number?
example:
3.1415926 only get two value after decimal point.

max
0
Comment
Question by:MaxTo
2 Comments
 
LVL 9

Expert Comment

by:j3one
ID: 10915376
0
 
LVL 9

Accepted Solution

by:
krishnaprathab earned 50 total points
ID: 10915427
Use this function:

//set number to 2 decimal places
//You can set this anywhere in your timeline and use as you need anywhere in your movie.

Math.__proto__.dec2 = function (num){

valor = String (Math.round(num * 100) / 100);
dot = valor.indexOf(".");

if(dot == -1){
valor += ".0";
}
temp = valor.split(".");
addDecimals = 2 - temp[1].length;
for(i=1; i<= addDecimals; i++){
valor += "0";
}
return valor;
};

Example:

a = 0.5;
b = 0.8;
z = Math.dec2(5);//if you trace thism, z will display "5.00"
z = Math.dec2(a + b);//if you trace thism, z will display "1.30"


PN: I have not written this code i found it in Actionscript.org

Thanks,
kp
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to record live broadcast.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question