
Key: DMN13125

Status: open

Source: Red Hat ( Matteo Mortari)

Summary:
(please discard the previous JIRA on subject made by me, THIS is the correct one)
The spec defines "modulo" FEEL builtin function as: "the remainder of the division of dividend by divisor"
However, this might be subject to ambiguity in the case the Divisor or Dividend are negative, as also mentioned by Wikipedia page which list examples out of several programming languages and systems: https://en.wikipedia.org/wiki/Modulo_operation by saying that "When either a or n is negative, the naive definition breaks down and programming languages differ in how these values are defined".FEEL aims to be a Friendly Enough expression language, and especially thinking about DMN practitioners who might be used to Spreadsheet based systems might find misleading if the definition of the FEEL "modulo" gets bind to the Java (default) definition, the following table illustrate the difference:
Dividend Divisor MOD() from Microsoft Excel, Google Sheets, LibreOffice Calc, Wolfram Alpha, etc. Java % or BigDecimal#remainder or other languages default 10 4 2 2 10 4 2 2 10 4 2 2 10 4 2 2 or to other implementation languages where the definition of Modulo/Remainder is not explicit, or the default one is not consistent with Spreadsheet default one.
It is proposed therefore to change the specification in 10.3.4.5 Numeric functions Table 70 for the FEEL "modulo" builtin function
FROM: "Returns the remainder of the division of dividend by divisor."
TO: "Returns the remainder of the division of dividend by divisor. In case either dividend or divisor is negative, the result has the same sign of the DIVISOR."This would avoid ambiguity by making a clear definition of what should be the sign in case either of the operands are negative.
This should make this consistent with Spreadsheet based system result of "MOD()" expression, which should address being Friendly Enough for DMN practitioners and DM analyst.
This would not make the result the same as the default of Java % operator or BigDecimal#remainder, but Java based implementation/Vendor can trivially address the result to be compliant with the spec. 
Reported: DMN 1.2b1 — Fri, 4 Jan 2019 18:38 GMT

Updated: Tue, 7 May 2019 14:52 GMT

Attachments:
 Screenshot_20190305150315_Excel.jpg 471 kB (image/jpeg)
 Selection_202.png 22 kB (image/png)
DMN13 — Disambiguation for Modulo / Remainder function
 Key: DMN13125
 OMG Task Force: Decision Model and Notation 1.3 RTF