Skip to content

Commit

Permalink
Fix incorrect sign bug for small decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiayue Charles Lin committed Jul 20, 2023
1 parent 512c81d commit 66e41d9
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 66e41d9

Please sign in to comment.