Thread Tools Display Modes
06-13-08, 03:05 PM   #1
madmaurice
A Defias Bandit
Join Date: Jun 2008
Posts: 3
modulo?

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
  Reply With Quote
06-13-08, 03:23 PM   #2
DocEVL
A Cobalt Mageweaver
 
DocEVL's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 232
Originally Posted by madmaurice View Post
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.
__________________
"Imagine all the people living life in peace" - J. Lennon



Last edited by DocEVL : 06-13-08 at 03:28 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » modulo?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off