Skip to content

Commit

Permalink
fix: Fix printing max scale decimals (pola-rs#16048)
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego authored and Wouittone committed Jun 22, 2024
1 parent 2dfa217 commit 267e27c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/polars-arrow/src/compute/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl FormatBuffer {
}
}

const POW10: [i128; 38] = [
const POW10: [i128; 39] = [
1,
10,
100,
Expand Down Expand Up @@ -173,6 +173,7 @@ const POW10: [i128; 38] = [
100000000000000000000000000000000000,
1000000000000000000000000000000000000,
10000000000000000000000000000000000000,
100000000000000000000000000000000000000,
];

pub fn format_decimal(v: i128, scale: usize, trim_zeros: bool) -> FormatBuffer {
Expand Down
13 changes: 13 additions & 0 deletions py-polars/tests/unit/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,16 @@ def test_format_numeric_locale_options() -> None:
│ yy ┆ -234567.89 ┆ 44444444444 ┆ -9999999.9900 │
└─────┴───────────────┴─────────────┴───────────────┘"""
)


def test_fmt_decimal_max_scale() -> None:
values = [D("0.14282911023321884847623576259639164703")]
dtype = pl.Decimal(precision=38, scale=38)
s = pl.Series(values, dtype=dtype)
result = str(s)
expected = """shape: (1,)
Series: '' [decimal[38,38]]
[
0.14282911023321884847623576259639164703
]"""
assert result == expected

0 comments on commit 267e27c

Please sign in to comment.