Skip to content

Conversation

@mattsu2020
Copy link
Contributor

Creating and modifying test cases to ensure od-float.sh passes tests

related
#9127

mattsu2020 and others added 8 commits November 29, 2025 21:00
Implement trim_float_repr() to remove trailing zeros from float strings while preserving signs and exponents, and pad_float_repr() to align trimmed floats to fixed width. Update format_item_f16() and format_item_bf16() to produce compact output matching GNU od. Add regression tests for float16 and bfloat16 compact printing.
…ility

Reformat the format! macro call in the format_item_bf16 function in prn_float.rs
to span multiple lines, improving code readability without changing functionality.
Remove trimming of trailing zeros from f16 and bf16 float representations
in od output to maintain original precision and align behavior with
f32/f64 formatters, ensuring stable output across platforms. Update
corresponding tests to reflect the change in expected output.
- Remove redundant `width = width` parameter from `format!` macro in `pad_float_repr`
- Add "bfloat" to spell-checker ignore list for better test coverage on bf16 format
Add `trim_trailing_zeros` function to remove trailing zeros and redundant decimal points from formatted floats, ensuring compact output matching GNU od for f16 and bf16 types. Update `format_item_f16` and `format_item_bf16` to apply trimming before padding.
…NU od output

Remove the `trim_trailing_zeros` function and update `format_item_f16` and `format_item_bf16` to keep the raw formatted strings without trimming trailing zeros. This ensures consistent column widths and aligns with GNU od behavior for 16-bit float representations, preventing misalignment in output tables.
… format_item_f16

The format! macro call in format_item_f16 was split across multiple lines with newlines. This change consolidates it into a single line for improved code readability and consistency with similar patterns in the file, without altering the function's output or logic.
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

@mattsu2020 mattsu2020 marked this pull request as draft December 1, 2025 03:52
…tputs

- Add `trim_float_repr` function to remove unnecessary trailing zeros and padding from normalized float strings, leaving exponents unchanged.
- Update `format_item_f16` and `format_item_bf16` to apply trimming while maintaining column alignment via re-padding.
- Update test expectations to reflect the more compact float representations (e.g., "1" instead of "1.0000000").
Replace `if let Some(_) = s.find('.')` with `s.find('.').is_some()` in the `trim_float_repr` function to improve code clarity and idiomatic Rust usage while maintaining the same logic for checking decimal presence=black.
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/od/od-float is no longer failing!

1 similar comment
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/od/od-float is no longer failing!

@mattsu2020 mattsu2020 marked this pull request as ready for review December 1, 2025 05:11
Co-authored-by: Daniel Hofstetter <[email protected]>
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/od/od-float is no longer failing!

@cakebaker cakebaker merged commit 003f21a into uutils:main Dec 1, 2025
126 of 127 checks passed
@cakebaker
Copy link
Contributor

Congrats! The gnu test tests/od/od-float is no longer failing!

Great, thanks!

@mattsu2020 mattsu2020 deleted the od_od-float.sh branch December 1, 2025 14:27
romanstingler pushed a commit to romanstingler/coreutils that referenced this pull request Dec 14, 2025
* feat: add compact float formatting for half and bfloat16 in od

Implement trim_float_repr() to remove trailing zeros from float strings while preserving signs and exponents, and pad_float_repr() to align trimmed floats to fixed width. Update format_item_f16() and format_item_bf16() to produce compact output matching GNU od. Add regression tests for float16 and bfloat16 compact printing.

* refactor(od): format multiline format! in format_item_bf16 for readability

Reformat the format! macro call in the format_item_bf16 function in prn_float.rs
to span multiple lines, improving code readability without changing functionality.

* fix(od): preserve canonical precision for f16/bf16 float formats

Remove trimming of trailing zeros from f16 and bf16 float representations
in od output to maintain original precision and align behavior with
f32/f64 formatters, ensuring stable output across platforms. Update
corresponding tests to reflect the change in expected output.

* refactor(od): simplify float padding format and update tests

- Remove redundant `width = width` parameter from `format!` macro in `pad_float_repr`
- Add "bfloat" to spell-checker ignore list for better test coverage on bf16 format

* feat(od): trim trailing zeros in float outputs for GNU compatibility

Add `trim_trailing_zeros` function to remove trailing zeros and redundant decimal points from formatted floats, ensuring compact output matching GNU od for f16 and bf16 types. Update `format_item_f16` and `format_item_bf16` to apply trimming before padding.

* fix: preserve trailing zeros in F16 and BF16 float formats to match GNU od output

Remove the `trim_trailing_zeros` function and update `format_item_f16` and `format_item_bf16` to keep the raw formatted strings without trimming trailing zeros. This ensures consistent column widths and aligns with GNU od behavior for 16-bit float representations, preventing misalignment in output tables.

* refactor(od/prn_float): combine multiline format! into single line in format_item_f16

The format! macro call in format_item_f16 was split across multiple lines with newlines. This change consolidates it into a single line for improved code readability and consistency with similar patterns in the file, without altering the function's output or logic.

* feat(od): trim trailing zeros in half-precision and bfloat16 float outputs

- Add `trim_float_repr` function to remove unnecessary trailing zeros and padding from normalized float strings, leaving exponents unchanged.
- Update `format_item_f16` and `format_item_bf16` to apply trimming while maintaining column alignment via re-padding.
- Update test expectations to reflect the more compact float representations (e.g., "1" instead of "1.0000000").

* refactor: simplify float trimming condition in prn_float.rs

Replace `if let Some(_) = s.find('.')` with `s.find('.').is_some()` in the `trim_float_repr` function to improve code clarity and idiomatic Rust usage while maintaining the same logic for checking decimal presence=black.

* Update src/uu/od/src/prn_float.rs

Co-authored-by: Daniel Hofstetter <[email protected]>

---------

Co-authored-by: Daniel Hofstetter <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants