Skip to content

Commit

Permalink
[BUG] Fix incorrect sign bug for small decimals (#1204)
Browse files Browse the repository at this point in the history
Co-authored-by: Xiayue Charles Lin <[email protected]>
  • Loading branch information
xcharleslin and Xiayue Charles Lin committed Aug 1, 2023
1 parent bd4235e commit 2df0e0f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/daft-core/src/array/ops/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,11 @@ pub(super) fn decimal128_to_str(val: i128, _precision: u8, scale: i8) -> String
if scale == 0 {
format!("{}", integral)
} else {
let sign = if val < 0 { "-" } else { "" };
let integral = integral.abs();
let decimals = (val % modulus).abs();
let scale = scale as usize;
format!("{}.{:0scale$}", integral, decimals)
format!("{}{}.{:0scale$}", sign, integral, decimals)
}
}
}
Expand Down

0 comments on commit 2df0e0f

Please sign in to comment.