← power operator page · numeric/power/sc_comp/integer_exponents

Integer exponents 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

power of a scalar base with the exponent in a component, inside calc.

Manual:

Power types exponent as component<number> | number, so it may be a component while the base is a scalar.

Expected:

Me_2 = power(2, Me_1): 2^3 = 8, 2^-1 = 0.5 and 2^10 = 1024, a Number although both operands are Integers; the other components are kept.

script.vtl ⇩

DS_r := DS_1[calc Me_2 := power(2, Me_1)];

input/DS_1.csv ⇩

Id_1Me_1
13
2-1
310

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}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1Me_2
138.000000
2-10.500000
3101024.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"}
      ]
    }
  ]
}