ActionScript 3.0 :: Set Decimal In Floating Number?
Nov 16, 2009here i have value of have long number after decimal. Now, I want to control in 3 digit after decimal. How could i do
Ex:
Problem = 9.982540214587
Want = 9.982
here i have value of have long number after decimal. Now, I want to control in 3 digit after decimal. How could i do
Ex:
Problem = 9.982540214587
Want = 9.982
i have value of have long number after decimal. Now, I want to control in 3 digit after decimal. How could i do.
View 1 Repliesthere is any method to check if a number is a decimal number or not? i searched in the help-panel, but didn't found something.
View 6 RepliesIs NaN stored as a floating a number? and if not, how does the computer stores it?PS: I know that NaN = Not a Number but still, flash needs to store it somehow.
View 2 RepliesI want to get decimal part of the number in this case 67 (number = 67 ) First problem is internal calculations
ActionScript Code:
var number:Number = 987123456.67;
var intNum:Number = Math.floor(number);
var decimal = parseFloat(String(number - intNum));
trace(decimal); //outputs 0.6699999570846558, instead of 0.67
I wonder is there a any way to doit besides using toString?
I'm making a game where you level up, and then the amount of EXP you need to level up, gets higher. The problem is, if I have it so the amount of EXP needed to get to the next level just multiply by 2, it just gets to an absurdly high number, and I don't want that. I would rather have it multiply by 1.3 or 1.5, but the problem with that is that the right side of the decimal gets all ugly to something like "60.54902380".
how would I be able to round it so there's no decimal point, or at best just one number to the right?
how do you set a number to 2 decimal places??
View 7 RepliesHow can I round off a decimal number upto say three decimal places? The number comes as an output value like 0.98765e^7 for the statement outputvalue = 0.8678/InputValue. How can I make the output value rounded off as 0.988e^7?
View 7 RepliesI want to get rounded number
Example:
I want to get full number I write
Code:
cas=15.02
int(cas)
and I get 15
But when I write these
Code:
cas=15.02
lol=cas - int(cas)
trace(lol)
I get 0.0199999999999996 instead of 0.02. I need to get only decimals so that i will be able to write 15.02 like 15:02 or 1.2 like 01:20. I need to write numbers like in digital clock.
I am totally confused about this one. I am trying to display a number as x.xx, but I'm having problems! The number has 0, 1 or 2 decimal places, so I have an if else to add '0' or '.00' on the end if there are 1 or 0 decimal places respectively.[code]...
View 3 Replieswhy does this not work for counting the number of decimals?
Code:
var num:Number = 4.321;
counter=0
while (num%1!=0) {
[Code]....
what actionscript do i need to round off a number to 2 decimal points? i have this script which brings me the number but consisting of 8 digits!
digital = _root.val[0].substr(0,_root.val[0].indexOf("<br>"));
digital = Math.abs(digital);
trace(digital);
[Code].....
how I can format numbers in Flash so that it will show two decimal places regardless of the number itself?
View 4 RepliesI'm trying to calculate loan payments using actionscript.
i'd like to have my variable's value like this:
843.34
instead of:
843.3454 (how it's displaying now)
since I'm ultimately going to display $dollar amounts.
I know how to use Math.round() but I'd like to go to two decimal places!
What is the Math.???? for making a number always have 2 decimal places?
View 5 RepliesI have tried and tried but i cannot get a number to force show 2 decimal places.I have lots of different buttons and selection boxes that output a different value for 'sizePrice' and 'effectPrize'. An example can be seen below:
Code:
if (sizeSelectionBox.value=="size1") {
sizePrice=67.20;
calcTotalPrice();
[code]...
I need totalCost to always show 2 decimal places so if it is 60 it needs to say 60.00, if it is 67.2 it needs to say 67.20
I looked everywhere on the internet and couldnt find how to generate a random number that had one decimal place.I am trying to generate numbers between 12.0 and 13.0 randomly.Below is my code... I know its wrong because of Math.round and Math.random, but i cant seem to find anything that deals with a decimal place.
addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_1);
function fl_EnterFrameHandler_1(event:Event):void{volt.text = Math.round(Math.random()*(1)+12).toString();}
[code].....
I have the following NumericStepper:
<s:NumericStepper id="estimertTidCell" value="{isNaN(hostComponent.estimertTid)?0:hostComponent.estimertTid}" stepSize="0.5" maximum="5" change="hostComponent.estimertTid=estimertTidCell.value"/>
When i set the value to e.g. 1.5 through the NumericStepper and store the value, the alert in the following code correctly displays 1.5:
private var _estimertTid:Number;
[Bindable]
public function get estimertTid():Number {
[code]....
Problem: My problem is that once the NumericStepper refreshes, or reloads the variable, it displays 2 instead of 1.5, or 4 instead of 3.5 etc. Anyone got any ideas of what is causing this behavior? I would think that by setting the stepSize=0.5 it would correctly display those decimal numbers.Additional information: When i display the same variable in a spark Label, the value is correctly displayed as a decimal number.
I am rather new to actionscript and having some trouble. My goal is to make a app where the user enters a decimal number and the number of decimal places and the output is displayed in a dynamic text box. Here's what I have so far:
ActionScript Code:
go_btn.addEventListener(MouseEvent.CLICK,Display);
function round(num:Number, dp:int):Number {
var decimal:Number = Math.pow(10, dp);
trace(Math.round(decimals * num) / decimal)
[Code]...
I've got a calculator that i created in as2 that converts different units of measurement. However, right now it always converts the numbers into a decimal number like 0.33333333 or 450.72. How in the world would i convert these decimal numbers to scientific notation? For example, say i have a number: 12,700. Expressed in scientific notation, this would be 1.27x10^4.I hope there is an easy way to make flash convert to such a number system? I know its easy to round numbers in decimal, but have never worked with scientific notation before.
View 9 RepliesI have tried and tried but i cannot get a number to force show 2 decimal places.
I have lots of different buttons and selection boxes that output a different value for 'sizePrice' and 'effectPrize'. An example can be seen below:
Code:
if (sizeSelectionBox.value=="size1") {
sizePrice=67.20;
calcTotalPrice();
[Code]....
I need totalCost to always show 2 decimal places so if it is 60 it needs to say 60.00, if it is 67.2 it needs to say 67.20
I thought the *100/100 should do it but its no
making my number value to 2 decimal places...
I have 2 string that contain a number in dynamic text (pricing_txt /pricing_txt2) that i have turned into numbers (myNumber/myNumber2). I then have a calculation that adds these two together and i need the result to be 2 decimal places long.
I have used the code
Code:
("number"*100)/100
which from looking on mny sites should solve the problem but it is still not working. My code is below...
Code:
var myString:String = pricing_txt.text;
var myString2:String = pricing2_txt.text;
var myNumber:Number = Number(myString);
[Code].....
I am having some problems making my number value to 2 decimal places...
I have 2 string that contain a number in dynamic text (pricing_txt /pricing_txt2) that i have turned into numbers (myNumber/myNumber2). I then have a calculation that adds these two together and i need the result to be 2 decimal places long.
I have used the code
Code:
("number"*100)/100
which from looking on mny sites should solve the problem but it is still not working. My code is below...
Code:
var myString:String = pricing_txt.text;
var myString2:String = pricing2_txt.text;
var myNumber:Number = Number(myString);
[Code].....
I have a Number type variable that is outputting as 3.46666666 I want it to round it up to 1 decimal place i.e., 3.6 so I can display it in a text field what do I do any ideas?
View 2 RepliesI am converting a number to string
var myResult : Number = 12.6789345
var myString : String ;
myString = String (myResult);
I am trying to search . (decimal point)
if ( myString.search("."){
}
But I am unable to get Result or unable to find " DOT ".
Having a problem with a little animation involving balloons floating in and then floating out again when a condition is met. There are two ways they can float in or out: from left to right, or completely randomly. I actually like it as coming in (left to right) and going out (random) but it's essentially up to the user.
Since I moved my Array sort code into the function that basically deals with telling the balloons to float off though, I've been having problems. Sometimes one or a couple of the balloons will not float off and I'm kind of boggled as to why. Because it works fine IF the Array sort part is outside this function, I'm wondering whether, when the for loop at the bottom starts running, the Array is still being sorted and that's why some balloons get left behind.
[Code]....
I am making a flash game for a school project, and I decided to make a stick fighting game.once the enemy attacks the player their health just drains. The only way I can fix it is if I have a decimal instead of a whole number, but I have the variable of the health in a text box to display the players current health and it doesn't look to good with a decimal number.So, I am wondering if there is a way to make the health decrease by a decimal, but show a whole number in the textbox.[code]
View 2 RepliesI have colour values from a Flash application that are ARGB format(A being the alpha/transparency value). I have to convert that long decimal number to a RGB/Hexadecimal number in Javascript. Do you know how I can extract the individual R, G, B & A values from a long(8 digit) number? Here's my function which converts a number to hexadecimal BUT its not good enough because it needs to convert the values individually(R,G,B,A):
[Code]....
Dear Guys I Want To Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number I Mean If For Example Already Generated Number "2" Next Time Did Not Generate It , Is There Any Solution
View 5 RepliesI Want To Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number I Mean If For Example Already Generated Number "2" Next Time Did Not Generate It,
View 4 Replies