Skip to content

Real to Decimal generate unexpected results #172

Description

KQL query below

let dt = datatable (Int: int, String: string, Bool:bool, Double: double, Decimal: decimal)
[
    1, 'a', false, 0.0,  0.0,
    2, 'b', true,  1.2,  2.2,
    3, 'c', false, 1.1,  2.3,
    4, 'a', false, 0.0, '0.0',
    5, 'b', true,  1.2, '2.2',
    6, 'c', false, 1.1, '2.3',
    7, 'a', false, 0.0,  decimal(0.0),
    8, 'b', true,  1.2,  decimal(2.2),
    9, 'c', false, 1.1,  decimal(2.3),
];
dt

will generate a table containing these rows

Int String Bool Double Decimal
1 a FALSE 0 0
2 b TRUE 1.2 2.2000000000000002
3 c FALSE 1.1 2.2999999999999998
4 a FALSE 0 0
5 b TRUE 1.2 2.2
6 c FALSE 1.1 2.3
7 a FALSE 0 0
8 b TRUE 1.2 2.2
9 c FALSE 1.1 2.3

Is this by design? If so, is it documented anywhere? I'm sure it can feel unexpected to some.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions