Solved

How to set floating point for number

Posted on 2004-04-25
2
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

734 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