Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Conversion Of Decimal System Question



can some please explain why

Code:
num = new Date().getTime();
trace(num);
the_str = num.toString(8);
trace(the_str);
num = parseInt(the_str, 8);
trace(num);
displays:

1091214333762
2134253502
292640578

I would think it would display:

1091214333762 <-- origional
2134253502 <-- convert to OCT
1091214333762 <-- back to origional



FlashKit > Flash Help > Flash MX
Posted on: 07-30-2004, 03:12 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Decimal-Binary Conversion
Again, reading one of the actionscript articles I ran into a script (in the Binary-Decimal Conversion Article) that I didnt understand completely.


Code:
// convert decimal number to binary string
function dec2bin(iNumber) {
var bin = "";
var oNumber = iNumber;
//this while method constructs a string from the number you enter as iNumber when you call the function
while (iNumber>0) {
if (iNumber%2) {
bin = "1"+bin;
} else {
bin = "0"+bin;
}
iNumber = Math.floor(iNumber/2);
}
// left pad with zeros
/*while (bin.length<15) {

bin = "0"+bin;

}*/
return bin;
}
Could anyone explain this piece of code for me.
Maybe by taking a decimal number as example and saying what Flash does with it, in the while loop, or smth

Thanks in advance

Convert A Number From DECIMAL NUMERATION SYSTEM To Binary
Is there any function i can use to convert a number from the decimal number system to binary mode? I used i function i created (it works converting a number to binary like we would do by hand) but it is very slow. Is there any faster way?

Flash.system.System.totalMemory Different Than Windows Mem Display
Anyone know why flash.system.System.totalMemory is much different than what I see FlashPlayer taking up in the Windows Task Manager?

I would expect to see some overhead, but the differences I'm seeing are quite large (i.e. 80MB vs 150MB).

Thanks

What Does System.capabilities.language Return On Your System?
I am working on a multi-lingual web site that automatically detects the user's OS or browser language by using System.capabilities.language .

Since I am running a german OS/browser, this returns 'de' in my case, but I wonder what it returns on other systems (english, french, spanish etc.)

To find this out, please copy and paste this code into a Flash doc and see what it says:

trace( System.capabilities.language );

Thx!

Mike

System.pause(); And System.resume();
I've been looking for a simple way to pause everything inside the flash player when a user clicks on a pause button. I found what I thought to be a solution by running System.pause() method. This sounds funny but the problem is that this method does exactly what it's supposed to do, meaning it pauses EVERYTHING.

There is another System method call resume(). But with the entire player pause, how is one supposed to call this method when the pause button is clicked a second time?

This is what I thought about using:


ActionScript Code:
public function pauseSystem(evt:MouseEvent):void {
            if(!sytemPaused){
                sytemPaused = true;
                System.pause();
            } else {
                sytemPaused = false;
                System.resume();
            }
        }

But once the pause() method runs, nothing is clickable. I've got tons of event listeners and things happen all at once, so I'd rather not have to go through removing and adding event listeners every time the user clicks a pause button. Any ideas? Thanks.

Hex To Decimal
is there a function or anything in AS to convert decimal numbers(0-255) to Hexadecimal Numbers(0-FF)?
take a 3 randoms numbers to set the RBG of a MC.
Thanks alot!!!!!!!!!

Sin, Cos, Tan (in Decimal?)
using my calculator in decimal mode it returns 0.36 if i type tan 20

in flash when i do
Code:
trace(Math.tan(20))
i get 2.23716094422474

ive heard that flash operates in radons or something......... how do i get it to work in decimal????

Decimal To Hex
SO I'm trying to create a bunch of little blocks that are colored. The colors of the these blocks will increase like a gradient. Odd, but beleive me it's nessecary. Flash likes to use hex color codes. Ok great but how do I increment a hex code? Or even better how do I take a number like 200 for r (r being red) and convert it to hex? Then I could just convert all the 0-255 of each color and paste them together to make the hex code. This is all to be done in code. All automated. That's my issue.


Thanks,
Travis

Two Decimal Places Please.
Hello, is there a way to confine numbers in a dynamic text box to 2 decimal places rather than a whole long line of numbers?

Cheers - Turner2000

Decimal Places
can anybody tell me how i round a variable to a certain number of decimal places?

2 Decimal Places?
im doing a mathematical calc with variables and i want the answer displayed as £s. How can i ensure that there are two decimal places in the answer so that i dont get an answer of £9.5 etc

cheers

Decimal To Hex Function?
I need to use the hex code of characters.
I did not find a function like hex(character) or similar in flash 4. Now there is that very clumsy workaround:

1. set up a var table in a var inits frame:
hexDigit0 = "0"
hexDigit1 = "1"
hexDigit2 = "2"
...
hexDigit16 = "F"

2. convert char like this:
n = Ord(char)
h1 = Int(n / 16)
h2 = n - (h1 * 16)
hexChar = Eval("hexDigit" & h1) & Eval("hexDigit" & h2)

It seems to work fine, but i wonder if there is a undocumented function built in with vs 4?

sunday

Decimal Problems:
I’m having a strange problem with Flash5 actionscript…

All I am trying to do is run some simple math to solve for a percent change, but every time the code runs, it gives me a number with no decimals! Instead of .20668 it gives me 20668 and its pissing me off. Here is the code:

changeinsize = _root.screen._width/(_root.end_x-_root.start_x);
changeinypos = (_root.start_y-_root.screen._y)/_root.screen._height;
changeinxpos = (_root.screen._width/2)/(_root.start_x-_root.screen._x+((_root.end_x-_root.start_x)/2));

And ideas on how to get to output a multiple would be great!

Thanks again,
Dave

Multiply Decimal Only
Hey, here is one for you math guys.

I doing this:

z = _root._currentframe; (let's say I'm on frame 420)
z = z/32

That gives me: 13.125

Now take ONLY the decimal (.125) and multiply by a number (let's say 4)

.125*4 = 0.5

Leaving you with a display number of 13.5

Remember I want to keep the orignal whole number and show it with my new decimal

????
Mike

Decimal Case
Hi,

I need a problem with dynamic text filds to display decimal cases.

My function is:

function decimal (result) {
final = int(result*100)/100;
var dec = (final-(parseInt(final)));
if (dec == 0) {
final = (String(parseInt(final))+".00");
}
if ((length(dec))<4) {
final = (String(parseInt(final))+"."+(dec*10)+"0");
}
return (final);
}

I have looped objects that re-display the values to text filds, but always when the second case after the "." is zero , the second case is not displayed in the result.

Should someone help me?

thanks

Decimal Places
hi,
how do i get a calculation to always return with the same number of deciaml places?.
eg
4.00
3.95
1.11

thx

Decimal Places
hi,
is there a way to get a calculation displayed always to the same decimal places?
ie
1.00
2.85
4.01
etc

thx

Decimal Limiter
okey....

How can I limit numberstring to two decimals and show two decimal eaven when their value is 0. And if posible round last desimal to nearest five.

exsample:
123.456 -> 123.45
123.452 -> 123.40
123 -> 123.00

=/

Decimal Nightmare
I have an input text field where the user needs to enter 3 numbers. As the user enters the numbers I need to have the numbers display as starting from the tenths place and working up. To make this clearer lets say they were to enter "989" when the type the first 9 it needs to appear as .9; then when they type the "8" it needs to be 9.8 and lastly when they type the second 9 it needs to show up as 98.9.
Can anyone help me out, I don't have alot of actionscript experience so you may have to walk me through the code or just provide code that works. THANKS!

Converting A Hex Value To A Decimal
This is my code. Unfortunately it goes into an infinite loop or something. I dunno. I don't seem to see any problem. Hope someone can help. And thanks in advance.

function hexToDec(temp) {
var output = 0;
var count = 0;
while(temp != 0 || temp != NULL) {
digit = temp.charAt(temp.length - 1);
switch(digit) {
case "A":
digit = 10;
break;
case "B":
digit = 11;
break;
case "C":
digit = 12;
break;
case "D":
digit = 13;
break;
case "E":
digit = 14;
break;
case "F":
digit = 15;
break;
}
temp.slice(0, temp.length - 1);
output += digit * Math.pow(16, count);
}
return output;
}

[Edited by Puppy Chow on 09-06-2002 at 07:55 AM]

Help Me Set Decimal Precision
I have this file which I am attempting to set decimal precision. Take a look at the ActionSctipt here and tell me why this isn't working. View the URL of the .swf and the .fla
http://web.csuchico.edu/~rp15/CDES270B
//code form a button where yellow and x are dynamic textfields.
//When subtotal reaches 29.5, it should display $29.50, instead it
//renders $29.5.

on (release) {
yellow += 2.95;
subtotal += 2.95;
// test variables initialized
var test = 0;
var test_num = 0;
test_num = subtotal%1;
if (test_num == 0) {
// whole number, append two zeros
subtotal.toString();
x = "$"+subtotal+".00";
} else {
// not a whole number so append one zero
test = (subtotal*100)%2;
if (test == 0) {
subtotal.toString();
x = "$"+subtotal+"0";
} else {
subtotal.toString();
x = "$"+subtotal;
}
}
}

Decimal Control
Hi everybody

Does anyone know how to control the number of decimals in dynamic text.

Best regards
deVido

Decimal Points
i have a dynamic chart that displays values from mathmatical equations from other entered variables. The resulting values are price figures, so i need them to stop at 2 digits to the right of the decimal. how do i do this?

Decimal Places
Can anybody tell me how to limit the decimal places to 2 in the dyanamic text field? I have given a dynamic field a variable name. and I created a button to change its value by 0.1. But when I click the button the text box shows me many number of decimal places after a point. I want to limit it to 2 places
Thanks

Decimal Numbers
Hello,

I have a problem with an equation....
I divide a X number by 30.
This number X can be anything between 1 and 10 (ie 1,1.2,...)
I would like the result of this division to be formatted like this: xx.xx

Does anybody know how to do that ??

Thx
qali

Decimal Places
im kinda new to flash. Not really but theres a few things i dont know yet.

i dunno if its possible... i know it is in programming languages that are similar to actionscript so i thought it'd give it a shot. Anyway,

im doing some equations and stuff in the action script... like... to figure out the precentage of somehting. the 'thing' is out of 136. So theres 136 possibly points you can get...

Since its such a number, the equation will turn out with a bunch of decimal places

so im asking how i can make it so only one decimal point appears... like 55.3%
???
Please help

Thanks

Decimal Places
Hello!

I have a dynamic text which displays a number to however many decimal places it can fit in the text box. I'd like to make it show 2 decimal places, can anybody help?

Thanks you

2 Decimal Places, How?
I want to have a timer, in a game I'm creating.
I want the timer to be in seconds, with 2 decimals all the time! I.e. 41.10 sec. (not 41.1), or 7.00 (not 7). <-- was that an AND/OR error?

Well, how do I tell the "time-variable" to contain 2 decimals in every value?!

Decimal Places
hey how can i limit the number of decimal places displayed in an output of an equation? my code is for a preloader to show the percentage loaded but i don't want any decimal places...

onClipEvent (load) {
preload = " ";
}
onClipEvent (enterFrame) {
preload = _root.getBytesLoaded() / _root.getBytesTotal()*100 + "%";
if (_root.getBytesTotal() == _root.getBytesLoaded() ) {
preload = "done";
}
}

thanks guys

Round Off Decimal
I have a variable and a dynamic text box that shows that variable. the only problem is sometimes the variable has a decimal how do i have it os when the variable is say 3.3 it rounds it off giving it the variable of 3?

Only Two Decimal Places...
Hi, ive got a dynamic tetx box, and in each frame im adding 0.08 to it. But I only want it to show the number to 2 decimal places, can this be done?

Thanks for any help.

Decimal Points
ive got a box that displays a percentage, but how to i make it so that no decimal points are shown? ie: instead of showing 85.71%, show 86%

Getting Rid Of Decimal Point?
I created a simple calculator here http://www.alamofitness.com/macrocalc.html

I would like to know how to make each result in the 3 bottom fields,
show up as whole numbers instead of decimals. For example, if i enter
3200 calories,60 carb,10 protein, and 30 fat, the amount of fat shows
up as 106.6666667. I would like it to round up to 107

thanks

Decimal Problem
Hi, I have a movement script which works fine, the only problem is sometimes it results in a decimal which I think slows everything down and causes pixel fonts to look blurry. Is there any code I can add to make it allways end on a full number? My actionscrpiting is a little dusty but I would preseume something like:

if x < 1 and > -1 x = target

Any help would be greatly appreciated.


Code:
onClipEvent (load) {
_root.targIMAGE = 0;
}
onClipEvent (enterFrame) {
cIMAGE = this._x;
difIMAGE = cIMAGE-_root.targIMAGE;
setProperty(this, _x, cIMAGE-(difIMAGE/5));
}

Decimal Question
I have a variable text field with a number like 123456
and I want flash to be able to display that number as
12:34:56. How do I write actionscript that says for every 2 number slots divide by ":".

Any idea's?

Animating A Decimal
I have a number that I want to animate from 0 up to a total number.
The number changes everytime the flash file is loaded.
for example it could be something like:
var num:Number=0.45; or
var num:Number=2.12;
Ans so on

The problem is if I do something like


Code:
var num:Number=2.45;
var counter:Number=0.01;
var interval:Number;

interval=setInterval(animateNum,200);

function animateNum():Void{
var newCount=Number(counter=counter+0.01);
trace("newCount = "+newCount);

}
when it reaches 0.10 it shows as 0.1 then when it reaches 0.80 it traces as
newCount = 0.800000000000001.

Also when it reaches 1.00 it shows newCount = 1

How can I get it to always show a count up of 3 numbers or four if it reached
10.34

Thanks,

Decimal To Binary...?
Hi...
this might be a really dumb question, but isn't there some built-in method in AS3 to convert a decimal number to binary and vice-versa? I can't find it...seems ridiculous to write a method when there must be some C-level code to tap into that would do this much, much faster...
Thanks for any help!
Josh

Decimal Places...
hello!

i've been given the task of creating an insurance/tax calculator for work despite the fact that i am not a programmer or have the slightest idea how to write code. anyways, after 2 long weeks i've managed to get it working but i'm stuck when i try to display decimal places. basically, i want the numbers to display 2 decimal places and a comma once it reaches the thousands, ex. 1,234.56. i've been searching these forums for some time now and the related threads i have found, i can't seem to make it work with the code i already have. please put me out of my misery by helping me out!!! any help is appreciated.

attached is my flash file.

How To Return A Decimal Value
the following code:


Code:
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.round(Math.random()*(max-min+1)+(min-.5));
return randomNum;
}
..returns a random integer in between the range specified when triggering the action. now i need to make this number a decimal, i.e.: my return number should be something like '0.7' instead of '7'. how can i accomplish this?

thanks in advance,
- w

Decimal In Flash
I am trying to create a math presentation. I need to show a limit as it approaches 1. Unfortunately, in my dynamic text box that has the equation to figure the limit, it shows numbers like 2.133984399400 - e^4. I need it to show all the zeroes in the beginning to make the point.

Is there a setting or actionscript that would force it to show all of the decimal places? I have found a ton of tutorials and ideas on how to limit the decimal places, but I need just the opposite. It seems Flash only wants to go up to 10 places.

Thanks for any help you can give.

Natasha

Cut Decimal Places
Hi,
a perhaps basic question. I am getting some values of variables like 3.1, 3.7, 3.9 etc. Now I want to cut the decimal places to get 3 in this case. Or 2 for 2.0 to 2.9. How can I do this?

Thanks in advance

Decimal Problem...
value= int((20/7)*10)/10;
1) 2.8
value= int((20/7)*100)/100;
2) 2.85

the value was show correctly...
but
14/7....
it will return 2

how can I make the return value is 2.00
with 2 decima points?

Fraction To Decimal
Does any Math genius out there know the formula of decimal to fraction conversion including how to apply the fundamental rule of fractions (the fraction should be written in its lowest terms?)

Thanks

P

Decimal Places....
how do i determine the number of decimal places a user can key in in a input text box?

2 Decimal Points
can some one show mi a simple example using actionscript on how to set the output of my dynamic textbox to 2 decimal points which i want to use for currency.? ?? ?

To 4 Decimal Points
Ok i'm lost, even though I've asked this before.

I've got my file here http://home.exetel.com.au/twistedpancreas/images/test1.fla , calculating an equation.

But once again I need the answer to be to 4 decimal points (ie like an answer of 0.0393), but for the life of me I can't get it to work.

I tried *100 / 100 but i'm just confusing myself.

Sorry for my lack of knowledge, but i appreciate the help.

Alpha Decimal Bug AS 2.0?
Hello! I'm working on a photo gallery slideshow loading pictures externally. I have a setInterval to count up/down the "alpha" and up/down the "_x". The "_x" is working fine but the "alpha" only works when set to 25 or 50. I've been running traces on it when set to 5, 10 and 20 and it adds up a decimal value instead of a whole number. Been trying to get it right with Math.round but it wont count correct. Anyone have any idea of what this problem is about? I'll post an example for anyone to please have a look at...

trace returns: 9.765625

Anyone with ideas?









Attach Code

function myFunction(){
this._alpha = 10;
trace(this._alpha);
}
myFunction();

Decimal Part
if I have this number (or a var) but I only want to keep what is left after the period for example:
1.28 want to keep only .28
23.43 =>.43
45.00=>.00

how do I do that?
Thanks

Decimal Places
hi,

This might sound stupid..

Does anybody kknow how to restrict the decimal places values in a number?

for example.... if iam doing something like:

var n;
n=100/3;
input.text=n;

In the input textfield i want only 33.33 to appear rather than 33.3333...is there any way to do this, rather than restricting the size of the textfield??

pls help!!!

Copyright © 2005-08 www.BigResource.com, All rights reserved