Author: omniplex
Description:
MOD and DIV behave different than in any programming language I've heard of.
1: Apparently "x MOD y" is handled like "trunc(x) - trunc(y) * trunc(x / y)",
e.g. "8.9 mod 3 = 2", "8 mod 3.2 = 2", "8 mod 2.7 = 0".
2: "x DIV y" is a misleading synonym for "x / y", no integer division.
3: A desperately needed "trunc" is missing, see [[m:Template talk:YMD2MJD]].
Proposed "fix" (or rather feature request):
2': Let "x DIV y" return "trunc( x / y )" also known as integer division.
3': This improved DIV automagically offers "x DIV 1" to get "trunc( x )".
1': Let "x MOD y" return "x - y * (x DIV y)" using the improved DIV.
With these two fixes (not counting 2') porting algorithms like Euclid's
GCD or date + time calculations should be more straight forward.
Using two #ifexpr: plus two #expr: +/-"0.5 round 0" to emulate trunc is
a royal PITA for formulae needing dozens of signed integer divisions.
The equation x MOD y = x - y * (x DIV y) should be okay, otherwise kill
DIV, as is it's at best redundant (but more likely harmful).
Version: unspecified
Severity: trivial
URL: http://meta.wikimedia.org/wiki/Help:Calculation