What is the equivalent in Oracle SQL to have exactly same behavior of the Java % (Modulo) Operator?
Example Java:
System.out.println(9 % 4); // 1
As known Oracle SQL provides REMAINDER and MOD:
REMAINDER(9,4) /* 1 */
MOD(9,4) /* 1 */
It is not clear to me what the appropriate equivalent is here and how to evidence it.
CodePudding user response:
As Turing85 mentioned the Java's %
-operation and Oracle SQL's MOD
operation seems be equivalent.
Oracle
REMAINDER(11,-4) /* -1 */
REMAINDER(-11,-4) /* 1 */
MOD(11,-4) /* 3 */
MOD(-11,-4) /* -3 */
Java
11%-4 /* 3 */
-11%-4 /* -3 */