← power operator page · numeric/power/comp_comp/negative_and_fractional_exponents

Negative and fractional exponents 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

power with the exponent in a Number component, inside calc.

Manual:

Power types exponent as component<number> | number, and "power ( 5, -1 ) gives 0.2".

Expected:

Me_3 = power(Me_1, Me_2): 2^3.0 = 8.0, 5^-1.0 = 0.2 and 4^0.5 = 2.0, a Number; the other components are kept.

script.vtl ⇩

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

input/DS_1.csv ⇩

Id_1Me_1Me_2
123.0
25-1.0
340.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
123.0000008.000000
25-1.0000000.200000
340.5000002.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"}
      ]
    }
  ]
}