Originally Posted by madmaurice
is there any way to use module in the wow lua files. i tried the 'mod' operator as told in the lua documentations but it always causes an error
|
Do you mean modulus? IE as in getting the remainder of two numbers divided? It exists and should simply be mod(x,y) where x and y are the two numbers you want to divide and get the remainder. Now having said that it may not work how you expect.
ie:
Take -2 / 5 which equals -0.4:
This could be considered:
a) 0 with a remainder of -2 (since -2 = 1x5 + -2)
b) -1 with a remainder of 3 (since -2 = -1x5 + 3)
Now mod will return -2, but if you really wanted 3 then your not going to get it with the mod command.
This will not work in cases such as:
You want to create a hash table mapping an arbitrary integer "x" onto an array "type hash_table[47];"
You would want mod(x,47) to produce a result of 0..46 for all values of "x" even negative ones but that will not happen with mod.