← modulo operator page · numeric/modulo/sc_sc/negative_divisor

Negative divisor 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

the sign of the remainder when the divisor is negative: mod(SC_1, SC_2) with SC_1 = 5 and SC_2 = -2.

Manual:

Modulo: "mod ( 5, -2 ) gives -1".

Expected:

SC_r = -1, an Integer: the remainder takes the sign of the divisor.

script.vtl ⇩

SC_r := mod(SC_1, SC_2);

input/scalars.csv ⇩

SC_1SC_2
5-2

input/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_1", "type": "Integer"},
    {"name": "SC_2", "type": "Integer"}
  ]
}

expected/scalars.json ⇩

{
  "scalars": [
    {
      "name": "SC_r",
      "type": "Integer",
      "value": "-1"
    }
  ]
}