HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Arithmetic in WEdit

06-13-2003, 07:40 PM#1
combatken
More quick questions..

1) When dividing integers, does WEdit truncate or round?

2) Does WEdit have a modulus function? Suppose I have a leveling system with stats, and when you assign stat points, every 3rd stat point gives an additional point of mana or something. With modulus..

E: Player adds a statpt
A: If statpt % 3 = 0, then something

Not sure how to make that work..

3) Does WEdit follow the order of operations? () */ +- etc
06-13-2003, 08:20 PM#2
piRo-piOn
3) WEdit follows the order of operations but everything is in parenthesys... ie you start out with ( X [operation] Y ) if you set X = whatvere it will become ((X [o] Z) [o] Y)
06-13-2003, 09:57 PM#3
MicrosoftXP
1) not sure but see below

2) yes ModuloInteger(Argument, Divisor) for ints

what I do to solve 1 is:

# = number to divide
d = divisor

to round down use:
(# - #%d) / d

OR if you want to round up, replace # with (#-1) and add 1:
((#-1) - (#-1)%d) / d + 1


[note] dont round up if your using zero
06-13-2003, 10:47 PM#4
Peppar
2) Blizzard.j defines two modulo-functions, for real and integer:
Code:
integer ModuloInteger(integer dividend, integer divisor)
real ModuloReal(real dividend, real divisor)

There are equivalents for GUI as well, this one is for both real
and integer numbers:
Code:
Math - Modulo (Dividend MOD Divisor)

EDIT: Seems like it was already answered by MicrosoftXP. I'm a slow poster ^^.