Skip to content

Commit d2726f2

Browse files
authored
numfmt: apply prefix after scaling for --to-unit (#11684)
* numfmt: apply suffix after scaling * test_numfmt: remove ignore from prefix selection test
1 parent 9f0ac6b commit d2726f2

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

src/uu/numfmt/src/format.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,8 @@ fn transform_to(
487487
precision: usize,
488488
unit_separator: &str,
489489
) -> Result<String> {
490-
let (i2, s) = consider_suffix(s, opts.to, round_method, precision)?;
491-
let i2 = i2 / (opts.to_unit as f64);
490+
let i2 = s / (opts.to_unit as f64);
491+
let (i2, s) = consider_suffix(i2, opts.to, round_method, precision)?;
492492
Ok(match s {
493493
None => {
494494
format!(

tests/by-util/test_numfmt.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,12 +1436,8 @@ fn test_zero_pad_sign_order_issue_11664() {
14361436
.stdout_is("-00000009869647.00\n");
14371437
}
14381438

1439-
// https://github.com/uutils/coreutils/issues/11666
1440-
// `--to-unit=N` selects the output prefix based on the unscaled value
1441-
// instead of `value / N`.
14421439
#[test]
1443-
#[ignore = "GNU compat: see uutils/coreutils#11666"]
1444-
fn test_to_unit_prefix_selection_issue_11666() {
1440+
fn test_to_unit_prefix_selection() {
14451441
new_ucmd!()
14461442
.args(&["--to=iec-i", "--to-unit=885", "100000"])
14471443
.succeeds()

0 commit comments

Comments
 (0)