Solved

How to set floating point for number

Posted on 2004-04-25
2
164 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
Comment Utility
0
 
LVL 9

Accepted Solution

by:
krishnaprathab earned 50 total points
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Flash Slides/Presnetation 4 70
bandwidth 5 64
flash in chrome 4 65
File conversion question 5 54
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now