← modulo operator page · numeric/modulo/comp_comp/integer_mod_number

Integer mod number 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

the remainder of an Integer component divided by a Number component, inside calc.

Manual:

Modulo: "If one of the operands is of type number, then the other operand is implicitly cast to number and therefore the result has type number."

Expected:

Me_3 = mod(Me_1, Me_2): 7 mod 2.5 = 2.0, 9 mod 4.0 = 1.0 and 10 mod 3.5 = 3.0, a Number; the other components are kept.

script.vtl ⇩

DS_r := DS_1[calc Me_3 := mod(Me_1, Me_2)];

input/DS_1.csv ⇩

Id_1Me_1Me_2
172.5
294.0
3103.5

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "Integer", "role": "Measure", "nullable": true},
        {"name": "Me_2", "type": "Number", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1Me_2Me_3
172.5000002.000000
294.0000001.000000
3103.5000003.000000

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "Integer", "role": "Identifier"},
        {"name": "Me_1", "type": "Integer", "role": "Measure"},
        {"name": "Me_2", "type": "Number", "role": "Measure"},
        {"name": "Me_3", "type": "Number", "role": "Measure"}
      ]
    }
  ]
}