mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added DivisionOperatorFix option for signed integer division (#278)
* it changes the behavior of vanilla division operator to use signed integer division. Before it used signed division for floats but unsigned for integers. Added a new "div" operator for unsigned integer division. Moved mathematical script functions from ScriptUtils.hpp to new MathOps. Added include guard to sfall.h and main.h in modders pack.
This commit is contained in:
@@ -10,10 +10,10 @@
|
||||
#define below(a, b) (unsigned_comp(a, b) < 0)
|
||||
#define below_equal(a, b) (unsigned_comp(a, b) <= 0)
|
||||
|
||||
procedure unsigned_comp(variable a, variable b) begin
|
||||
// for sfall 4.2.3/3.8.23
|
||||
pure procedure unsigned_comp(variable a, variable b) begin
|
||||
if ((a bwxor b) == 0) then return 0; // a == b
|
||||
if (b == 0) then return 1;
|
||||
return 1 if (a / b) else -1;
|
||||
return 1 if ((b == 0) orElse a div b) else -1;
|
||||
end
|
||||
|
||||
#define MAX(x, y) ((x > y) * x + (x <= y) * y)
|
||||
|
||||
Reference in New Issue
Block a user