Skip to content

Trunc function with precision uses round instead of trunc semantics #19793

@kumarUjjawal

Description

@kumarUjjawal

Describe the bug

The trunc function with a precision argument incorrectly uses rounding semantics instead of truncation.

When calling [trunc(value, precision)] where precision > 0, the function uses f64::round() internally instead of f64::trunc(), causing values to be rounded to the nearest digit rather than truncated towards zero.

To Reproduce

SELECT trunc(3.76, 1);

Expected behavior

Should be truncated towards zero instead of rounds to nearest.

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions