Uploaded image for project: 'OASIS Open Data Protocol (OData) TC'
  1. OASIS Open Data Protocol (OData) TC
  2. ODATA-1004

Sign of Modulo for positive right operand

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.0_ERRATA03
    • Fix Version/s: V4.01_WD01
    • Component/s: URL Conventions
    • Labels:
      None
    • Environment:

      [Proposed]

    • Proposal:
      Hide

      State that the result of the mod operation has the same sign as the left operand.

      Show
      State that the result of the mod operation has the same sign as the left operand.

      Description

      The current description of Modulo reads:

      "If the right operand is negative, the sign of the result is the same as the sign of the left operand. If the right operand is zero, the request fails."

      This leaves (intentionally?) ambiguous what the sign of the result should be if the right operand is positive.

      Most programming languages appear to always use the sign of the left operand (C/C+, CoffeeScript, Fortran, Java, JavaScript, PHP, SQL, VB, XBase+,...) while some use the sign of the right operand (Ada, COBOL, Common LISP, Haskell, Excel, PERL, Python, R, Ruby,...) and some return a positive result always, but I didn't find any examples where the result was the sign of the left operand if, and only if, the right operand was negative.

      Note that MOST of the languages that use the sign of the right operand have variants for returning the sign of the left operand.

      We could specify:
      1) Sign is always the sign of the left operand (most commonly supported)
      2) Sign is always the sign of the right operand (less commonly supported)
      3) Sign is always positive
      4) Sign is explicitly undefined

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mikep Michael Pizzo
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: