← cast operator page · general/cast/number_to_string/plain_decimal_notation

Plain decimal notation 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

cast(Me_1, string) on a Number measure, without a mask: the default format.

Manual:

Type conversion: "From number: the number value may be printed either in the scientific notation, or as a sequence of digits, possibly preceded by a -, with . as the decimal separator, without any leading zeroes or thousands separators."

Expected:

The sequence of digits, 3.5 and -12.75, values exact in binary floating point; they are not between -1 and 1, so the reading of "without any leading zeroes" (0.5 or .5) does not matter. A scientific result, which the manual allows too, would not match these strings.

script.vtl ⇩

DS_r := DS_1[calc Me_2 := cast(Me_1, string)];

input/DS_1.csv ⇩

Id_1Me_1
13.5
2-12.75

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Me_1Me_2
13.53.5
2-12.75-12.75

expected/DS_r.json ⇩

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