Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions datafusion/functions/src/math/trunc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ fn trunc(args: &[ArrayRef]) -> Result<ArrayRef> {

fn compute_truncate32(x: f32, y: i64) -> f32 {
let factor = 10.0_f32.powi(y as i32);
(x * factor).round() / factor
(x * factor).trunc() / factor
}

fn compute_truncate64(x: f64, y: i64) -> f64 {
let factor = 10.0_f64.powi(y as i32);
(x * factor).round() / factor
(x * factor).trunc() / factor
}

#[cfg(test)]
Expand Down Expand Up @@ -238,9 +238,9 @@ mod test {

assert_eq!(floats.len(), 5);
assert_eq!(floats.value(0), 15.0);
assert_eq!(floats.value(1), 1_234.268);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this assertion removed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I might have accidently deleted the line during editing.

assert_eq!(floats.value(1), 1_234.267);
assert_eq!(floats.value(2), 1_233.12);
assert_eq!(floats.value(3), 3.312_98);
assert_eq!(floats.value(3), 3.312_97);
assert_eq!(floats.value(4), -21.123_4);
}

Expand All @@ -263,9 +263,9 @@ mod test {

assert_eq!(floats.len(), 5);
assert_eq!(floats.value(0), 5.0);
assert_eq!(floats.value(1), 234.268);
assert_eq!(floats.value(1), 234.267);
assert_eq!(floats.value(2), 123.12);
assert_eq!(floats.value(3), 123.312_98);
assert_eq!(floats.value(3), 123.312_97);
assert_eq!(floats.value(4), -321.123_1);
}

Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/scalar.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ from small_floats;
----
0.447 0.4 0.447
0.707 0.7 0.707
0.837 0.8 0.837
0.836 0.8 0.836
1 1 1

## bitwise and
Expand Down