a little AS math
- Started
- Last post
- 32 Responses
- talltyler0
thanks for the help, I am going to search for the answer elsewhere but you have both made me think about it some more and I am pretty sure I can do it. I am going to post a page of helpful math equations someday because math freak'n rock I wish I new more about it.
thanks for reading my post, if even if there was no good conclusion it is so much better than nothing at all.
- bk_shankz0
I think itou have to grab the ones digit and then use a modulo operator of 5 and then that will give you the group number. if the remainder is 0 than its in the last group. see % operator to get the remainder.
- bk_shankz0
onesPlace = num % 10
remainder = onesPlace % 5
if (remainder == 0) {
group = 5
} else {
group = remainder
}
- fate_redux0
bk_shankz, he wants a one-liner. The code I posted above would work, but he refuses if/then statements or loops.
- imakedesign0
why be so anal about how many line of code you use??
- bk_shankz0
one line could be difficult
- juanzo0
group = (num - 1) % 5 + 1;
- bk_shankz0
that's it!
- bk_shankz0
Tally already skedaddled though.
- talltyler0
hey thanks a lot I just got of the phone and figure the same thing out the mod operator.
but can I just say
group=x % 5do I need to add and subtract 1
but anyways, Math rocks.
- bk_shankz0
Its going to fuck up on 10 and 20 and so on though because you don't have a group zero.
- talltyler0
I see. that is why you need the plus and minus 1. Thanks.
group = (num - 1) % 5 + 1;