Posts ID:270440 Favorites Creations Medals
ID:270440

I trying to implement odd formulas (this one requiring the use of only remainders :) ) I need to check if the remainder of n divided by 4, equals 2 or 3.

How would I do this?

I'm starting to think this:

 ```if(text2num(copytext("[Attacker.HPIV/4]",lentext("[Attacker.HPIV/4]")-1,lentext("[Attacker.HPIV/4]")))==2) ... ```

But it looks a little long...
 #1 May 8 2006, 5:04 pm I need to check if the remainder of n divided by 4, equals 2 or 3. if(n % 4 == 2 || n % 4 == 3) ...
Mega fart cannon wrote:
I need to check if the remainder of n divided by 4, equals 2 or 3.

How would I do this?

If I understand what you want correctly, you should use the % operator. Something like the following should work:
 ```mob/verb/Remainder() var/A = n%4 if(A==2) world<<"The remainder is 2!" else if(A==3) world<<"The remainder is 3!" else world<<"The remainder is neither 2 or 3, but infact [A]!" ```

If you just want to know if it's 2 or 3, but doesn't matter which:
 ```if(n%4==2 || n%4==3) ```

*Edit*
Dratz, beaten again!
 #3 May 8 2006, 5:10 pm For integers, a simple if(n&2) will do. If you don't want to deal with bit flags, if(n%4>=2) works too. Lummox JR