mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ParserFunctions
synced 2024-11-15 20:09:43 +00:00
d9fd747f2d
Reimplement, but better! Use BC Math library where possible, for fixed-point math operations. The tolerance aspect has been included by doing math internally at 16 digits, but discarding the last two digits for the purpose of comparison.
40 lines
454 B
Plaintext
40 lines
454 B
Plaintext
1 + 1 = 2
|
|
-1 + 1 = 0
|
|
+1 + 1 = 2
|
|
4 * 4 = 16
|
|
-4 * -4 = 4 * 4
|
|
(1/3) * 3 = 1
|
|
3 / 1.5 = 2
|
|
3 mod 2 = 1
|
|
1 or 0
|
|
not (1 and 0)
|
|
not 0
|
|
4.0 round 0; 4
|
|
ceil 4; 4
|
|
floor 4; 4
|
|
4.5 round 0; 5
|
|
4.2 round 0; 4
|
|
-4.2 round 0; -4
|
|
-4.5 round 0; -5
|
|
-2.0 round 0; -2
|
|
ceil -3; -3
|
|
floor -6.0; -6
|
|
ceil 4.2; 5
|
|
ceil -4.5; -4
|
|
floor -4.5; -5
|
|
4 < 5
|
|
-5 < 2
|
|
-2 <= -2
|
|
abs(-2); 2
|
|
4 > 3
|
|
4 > -3
|
|
5 >= 2
|
|
2 >= 2
|
|
1 != 2
|
|
not (1 != 1)
|
|
1e4 = 10000
|
|
1e-2 = 0.01
|
|
ln(exp(1));1
|
|
trunc(4.5);4
|
|
trunc(-4.5);-4
|