?
Solved

How to set floating point for number

Posted on 2004-04-25
2
Medium Priority
?
174 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 150 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

741 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