ActionScript 2.0 :: Round To Specific Decimals With Scientific Numbers?
Oct 2, 2010This one seems though, as there isn't even a regular "round-to-specific-decimal" function.. (I know the work around for that though)[code]...
View 2 RepliesThis one seems though, as there isn't even a regular "round-to-specific-decimal" function.. (I know the work around for that though)[code]...
View 2 RepliesAs the title, is there a class method in Flash to limit and round of a number's decimals ?Like :roundToTwoDecimals(1.2362 ) = 1.24
View 8 RepliesI've this problem with rounding up. My problem is more complex than i describe here but I'm sure i can figure out the rest myself once I got this working. I want flash to round up with two decimals at all time.
[Code]....
I'm making a canadian tax calculator - and it all works BUT I need it to check the fields and if they're blank, make it process it as zero. ALSO, I've now discovered I need to make the fields display as money would. Is it possible to make the fields only show two decimal points, put a comma in (like --> 2,546.00) and have it everytime show two zeros (sometimes it displays as this --> 26.0 instead of 26.00. At the *least* I need it to show 26.0 >> like this ...26.00
View 1 RepliesI have a text field that displays a number from a variable. How can I make it so this number is always formatted to 2 decimal places?
For example, 1 would be changed to 1.00 and 1.5 would be 1.50, etc.
One more thing that I need for my calculator:
how do I turn the decimals into whole numbers if the number is:
10.56 I want my number to be 11
10.49 I want my number to be 10
these numbers are inside an input field.
I'm making an application in actionscript that deals a lot with numbers. One of the problems, which has been driving me nuts for a while now, is "almost integers". Essentially, if I do something like the square root of 3, then square it, it gives me 2.99999999999999 (this is just the easiest example to test with). I've tried forcing it to round to a certain decimal place ([URL]), using toFixed, toPrecision, and math.round.
I've been spending all afternoon on this, and have found that actionscript uses 15 point/precision floating numbers. So with the squareroot/square of 3 above, if I specify it to go to 14 decimal places/significant figures, it gives me 3.0000000000001 (essentially ending with a 1), and if I specify it to 15 digits, it gives me (2.9999999999999).
I'm pretty sure that Actionscript is trolling me, because if the number was 2.9999999999999 (15 digits) and I rounded it to 15 digits... it'd make sense to keep it the same because there is no number after the last 9. However, if I round it to 14 digits, shouldn't the 14th 9 (15th digit) be chopped off, and the 13th 9 (now the last digit) rounded up, and making it carry over until it just becomes 3? Where did the 1 come from when rounding to 14 digits? If there was a 9 before that, shouldn't it have made it round to 3 when rounding to 15 digits?
I don't understand why my number generates more than two decimal places after toFixed is applied. Am I misunderstanding the purpose of toFixed()?
Here is the code (one case in a switch):
Code:
case jewelry:
m_premIncrease = m_premData[m_selectedIndex][0][0] * m_premData[m_selectedIndex][3][0];
trace("Jewelry premium increase is " + m_premIncrease);
m_premIncrease.toFixed(2);
[Code]...
i have a bunch of movieclips inside a container movieclip.they all have really crazy coordinates, like x: 1590.24 and y: 696.66443i was wondering - is there an easy way to "quantize" them to round their coordinates to the closest integer?
View 2 RepliesI am trying to round some numbers in two decimal point and I run into a bizare behavior.
[Code]...
i got an easy question that i couldn't find the answer to. what line of code do i need to use to change 123.456789 to 123.45.
code
oldNum = 123.456789;
newNum = ???
I want to round specific corners of buttons to create something like mx.controls.ButtonBar. But I cannot figure out how ButtonBar does this even after looking at its source. I thought the focusRoundedCorners css property was the answer but that applies only to drawing the button's focus box.
View 1 RepliesIs there a way, or even better a class available in flash to help me round a number to a specific point. For example, I have need to have a number rounded to the nearest 15th, how would I do that?
View 7 RepliesI really need help with my code...okay how to put ".00" after round the numbers in 2 decimal places..this code works well with another numbers but if I'm try with this number it will output the numbers as "9" only.
[Code]...
how do you round a number to 4 digits... so 3.45356345345 is 3.456 and 1 is 1.000
View 5 RepliesI have the following: ActionScript Code: if ((player.charVelocity < 9.0180945396304027e-26 && player.charVelocity > -9.0180945396304027e-26)) it seems to be firing as soon as charVelocity gets between 1 and -1. Am I writing that correctly? I assume it would work as I copied the syntax it was outputting for the variable value (which is set to 'int')
View 5 Replieswhat do i really want is:
if i have numbers of frames 31,64,97,134,175...(between each of that frames i have motion tween, so it isnt 1,2,3,4...) i want that it goes random in the array of numbers but with no repeating (if i passed 64,175,134 i shure dont want to go on 175 again or something similar), and when that array is finished(all the frames are passed) i want from flash to go on exc. frame 205. Could somebody write that in as3 code? :roll:
I have 16 instances of the same movie clip. The movie clip is made up of 16 frames, each with the picture of a face on it. I want it to work such that when I click my button, each face only appears once, so that all 16 different faces are on the screen. I have been trying to use an array containing the numbers 1-16, and removing them as they are randomly selected. However, with the splice function, I can't pick and choose which number is removed.
How to I pick a random number from an array of 16 numbers, and then remove that specific number from the array so it can't be selected again?
I want to restrict a text box to to use a specific range of numbers, say from 35 to 40.[code]...
How do I restrict it to only allow the 6 numbers between 35 and 40?
Is my only option to use a control like a combo box and fill it with the numbers I want to appear?
what do i really want is:
if i have numbers of frames 31,64,97,134,175...(between each of that frames i have motion tween, so it isnt 1,2,3,4...) i want that it goes random in the array of numbers but with no repeating (if i passed 64,175,134 i shure dont want to go on 175 again or something similar), and when that array is finished(all the frames are passed) i want from flash to go on exc. frame 205.
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 Repliesif i have numbers of frames 31,64,97,134,175...(between each of that frames i have motion tween, so it isnt 1,2,3,4...).i want that it goes random in the array of numbers but with no repeating (if i passed 64,175,134 i shure dont want to go on 175 again or something similar), and when that array is finished(all the frames are passed) i want from flash to go on exc. frame 205.
View 2 RepliesI know how to remove all decimals with:
ActionScript Code:
Math.round (xTwo*0.39);
But, how do I keep 1 or 2 decimals?
Can I use a decimal in a variable name in AS2? I need to create a variable named SCC.Q2.
View 4 RepliesI have made a class for handling colors with decimals.It's not really impressive i think, but i made it because i needed something like this in my game: in the normal interpolateColor function of Color if you do: color1: 0xFFFFFE color2 0xFFFFFF and progress = 0.8, then the tint will be 0xFFFFFF, whereas with my class it will be 0xFFFFFE, and store a value of 0.8 for blue, so that the next time it is interpolated, that 0.8 will be taken into account.it then only needs a 0.2 to jump to 0xFFFFFF.Look especially at the last function, thats what the class is about.[code]....
View 2 RepliesIn AS3, from a division I get a number like this one: 0.9130406010219044.Is there any way to reduce the number of decimals (aside from multiplying that number for one million)? Is there a way to reduce the numbers BEFORE the division is performed?
View 5 RepliesI'm trying to do a pretty simple modulo equation but i'm getting a weird return.0.03 % 0.01I was expecting there to be no remainder, so the answer would be 0. However the return flash gives me is: 0.009999999999999998If I bump everything up to whole Numbers it works just fine: 3 % 1 = 0However I know eventually I'll be doing something like 3.4 % 1 and I'm concerned that at that point I'll run into this same issue.
View 4 RepliesI'm working on some banners in various sizes and I noticed that I can only enter a font size in full pixels but not in decimals. I can type them in but noting happens to the size.
View 1 Replieswhy it is not simple! i just want to restrict input text to allow only number with 2
[Code]...
how can i make it with actionscript 2.0 ?
I wonder if there's a more straightforward way to achieve this.[code]...
View 3 Replies