Skip to content

od: Add support for -t fL (long double, 80-bit on x86) #8426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

drinkcat
Copy link
Collaborator

@drinkcat drinkcat commented Aug 3, 2025

Fixes #3096, and part of of GNU's tests/od/od-float.

Some TODOs, for follow-up PR (I'll do some of it and file issues for the rest):

  • Performance is bad -- some of that is expected, but for example, we don't need all 100 digits of the default BigDecimal precision when doing the exponentiation.
  • I feel that on arm64, we should actually parse a f128 (IEEE 754-2008 binary128), and maybe fall back to f64 on arm.
  • prn_float.rs should also use uucore's formatting functions (that code is quite old), that'd make the printing a bit "better", i.e. just print 1 vs 1.000000. => that'll fix tests/od/od-float I think.
  • We don't exactly handle printing like GNU, but I think this might not matter too much (GNU seems to trim digits if it still lands unambiguously on the same binary representation).

test_od: Add f128 test (actually a f80 test)

od: Add printer for ExtendedBigDecimal (for f80/f128)

od: input_decoder: f80 parsing code for -t fL format

This replicates x86(-64) behaviour.

od: output_info: Add support for 16 byte long output

fL can consume 16 bytes at a time, so we need to be able to
generate correct padding.

Also add a simple test for such wider lines.

od: Start adding support for f128 (ExtendedBigDecimal-backed)

There is no (stable) support for f128 (yet?), and we need to parse
f80 anyway, so let's back the datatype with an ExtendedBigDecimal,
for now.

uucore: extendedbigdecimal: Add from_number_exp2 to compute num * 2**exp

Move the code from num_parser, as we have another usecase in od.

Copy link

github-actions bot commented Aug 3, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@drinkcat drinkcat marked this pull request as ready for review August 3, 2025 06:31
Copy link

github-actions bot commented Aug 3, 2025

GNU testsuite comparison:

GNU test failed: tests/test/test-N. tests/test/test-N is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/rm/fail-eperm is now passing!

Copy link

github-actions bot commented Aug 3, 2025

GNU testsuite comparison:

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

@drinkcat drinkcat changed the title Od f128 od: Add support for -t fL (long double, 80-bit on x86) Aug 4, 2025
Move the code from num_parser, as we have another usecase in od.
There is no (stable) support for f128 (yet?), and we need to parse
f80 anyway, so let's back the datatype with an ExtendedBigDecimal,
for now.
fL can consume 16 bytes at a time, so we need to be able to
generate correct padding.

Also add a simple test for such wider lines.
This replicates x86(-64) behaviour.
Copy link

github-actions bot commented Aug 6, 2025

GNU testsuite comparison:

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

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.

od: doesn't support output format specifier "fL"
1 participant