Skip to content

trunc(x) on a column turns -0.0 into 0.0 #25702

Description

@jonasdedden

trunc(x) drops the sign of -0.0, but only when it runs on a column. On a scalar, and for trunc(x, 0), the sign is kept.

SELECT trunc(column1), trunc(column1, 0) FROM (VALUES (CAST(-0.0 AS DOUBLE)));
-- got:      0.0, -0.0
-- expected: -0.0, -0.0

The column code path returns 0.0 for either zero:

if x == 0_f64 { 0_f64 } else { x.trunc() }

-0.0 == 0.0 is true, so -0.0 becomes 0.0. f64::trunc already keeps the sign, so plain x.trunc() would be enough.

Seen through Lance (pylance 12.0.0): trunc(x, 0) on a -0.0 column returns -0.0. This line is the same on main and in 55.1.0. I found no existing issue or PR for it.

Activity

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