a little AS math
- Started
- Last post
- 32 Responses
- talltyler
here is my problem,
you have five groups,
a counter that puts thing in these five groups so that 1 is in group 1, 2 is in group 2... and 6 is in group 1, 7 in 2, 8 in 3... 11 in 1 and so on.
So I need a equation that if I have number it will return what group it is inside of.
if it helps you can use and of the actionscript math functions.Thanks for the help.
- rabattski0
you only use 3 groups based on what you write above and not 5.
another question would be why is 6 in 1 and 7 in 2?
- talltyler0
1=1
2=2
3=3
4=4
5=5
6=1
7=2
8=3
9=4
10=5
11=1
12=2
13=3
14=4
15=5
16=1
17=2
ect.sorry I wasn't clear before
and hope that this is
- rabattski0
never mind, now i understand it.
this is the system right?12345
-------
12345
67890
12345
67890simple, look at the last position of a number.
if it's 1 or 6 it's group 1.
if it's 2 or 7 it's group 2.
if it's 3 or 8 it's group 3.
if it's 4 or 9 it's group 4.
if it's 5 or 0 it's group 5.
- rabattski0
for instance 756784 would be group 4. 212 group 2. 478627625 group 5. etc.
- talltyler0
yes you have it.
- rabattski0
the solution is simple, do the code yerself though. should be simple as well. figure out the length of the variable, check the last character of that variable. based on that you know what group it belongs to.
- fate_redux0
rabattski is the smart cookie. this may be a quicker way to code it though.
num=17
function run(){
for(i=0; i=num){
group=num-i
trace(group)
}
}
}
- talltyler0
no, I need to figure out what group something belongs to if all I know is the for instance 11
needs to return 1All I need is an equation.
What do you think?
- fate_redux0
I am so fucking tired of NT stripping out important code
- rabattski0
talltyler, did you read my posts at all? the last number will tell you which group it belongs to.
- talltyler0
I dont need a loop of any kind all I need is a equation.
I give it a number and it returns a group. No loops or if statements. Thanks
- rabattski0
do you want me to wipe your ass as well? diy buddy. you now know what to look for (besides you ARE asking for AS math).
- talltyler0
that isn't true, 6 and 16=1 I would get 6 if I did what you wrote. I am thinking I have to divide my number by 5 then subtract and round but I am not getting the write answer.
- fate_redux0
talltyler, did you even try my code?
- rabattski0
don't bother fate.
- rabattski0
both 6 and 16 belong to group 1, correct, because they belong to group 1, that's what you want. so what's your problem?
- talltyler0
Not that I have a big head or anything but I understand what your loop is doing and I know I can do this without a for loop involved. I am looking for something like this
x=givenNum
group=int((x/5)+5)or something to the effect of an equation. I dont need a loop or an if or anything else.
- fate_redux0
oh ok talltyler, you keep telling yourself that.
- talltyler0
sorry rabattski maybe I am not understanding something but are you saying something like
divide the number by 5 and then split the number at the decimal and then divide by 2.
ether that or I can find out
if(x>=5){
group=x
}else if(x=10){
group=x-5}ect.
But there has to be a way to do it with math, I just dont know,
can you point me at something, this seem easy I just dont do very much math
- rabattski0
i seriously don't think you can do an actionscript oneliner for this one.