Skip to content

Real to Decimal generate unexpected results #172

Closed

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.

Activity

  1. mattwar commented on Oct 7, 2025

    @mattwar
    Contributor

    Maybe it is due to the real value not having any implied precision, so it is converting to maximum precision, and you are seeing the floating-point representation. You should probably specify decimal data as decimal values.

  2. locked and limited conversation to collaborators on Oct 8, 2025
  3. converted this issue into a discussion #175 on Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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