Skip to content
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

Add ldexpf16, ldexpf128, scalbnf16, and scalbnf128 #391

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

tgross35
Copy link
Contributor

@tgross35 tgross35 commented Jan 3, 2025

The scalbn functions are similar enough that they can easily be made generic. Do so and f16 and f128 versions.

@tgross35
Copy link
Contributor Author

tgross35 commented Jan 3, 2025

f16 and f128 versions are untested, blocked until I can figure out how to do that with MPFR.

Edit: done in #392. I cherry picked that commit here but that one should probably merge first.

@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch 2 times, most recently from 13238e7 to 84597eb Compare January 3, 2025 04:43
@tgross35 tgross35 marked this pull request as ready for review January 3, 2025 05:34
@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch from 84597eb to 3d70168 Compare January 3, 2025 05:41
@tgross35 tgross35 force-pushed the tgross35/f16-f128-copysign-fabs branch from e6907f5 to 31a58aa Compare January 3, 2025 05:49
@tgross35 tgross35 changed the title Add scalbnf16 and scalbnf128 Add ldexpf16, ldexpf128, scalbnf16, and scalbnf128 Jan 3, 2025
@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch 4 times, most recently from 0b59cdc to c4eca7d Compare January 3, 2025 06:27
@tgross35 tgross35 marked this pull request as draft January 3, 2025 06:33
@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch from c3df336 to b0e4038 Compare January 3, 2025 08:48
@tgross35 tgross35 force-pushed the tgross35/f16-f128-copysign-fabs branch 2 times, most recently from b1b01c5 to 58775fc Compare January 4, 2025 00:25
@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch from b0e4038 to cd3ef7a Compare January 4, 2025 00:27
@tgross35 tgross35 force-pushed the tgross35/f16-f128-copysign-fabs branch 2 times, most recently from b617507 to 336a6b6 Compare January 6, 2025 09:10
Base automatically changed from tgross35/f16-f128-copysign-fabs to master January 6, 2025 09:25
@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch from cd3ef7a to b801ddd Compare January 6, 2025 11:54
@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch 2 times, most recently from e9d7e6c to 4d58493 Compare January 23, 2025 11:54
@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch from 4d58493 to c997735 Compare January 23, 2025 23:20
@tgross35
Copy link
Contributor Author

I think the f16 version is running into the same issue as #419 (comment) (among other issues) so I am just going to drop that for now, keeping only scalbnf128.

@tgross35
Copy link
Contributor Author

Oh, interesting; the same problem seems to be showing up for the f128 version:

thread 'mp_edge_case_scalbnf128' panicked at crates/libm-test/tests/multiprecision.rs:17:48:
called `Result::unwrap()` on an `Err` value:
    input:    (0x00000000000000000000000000000003, -2) (0x00000000000000000000000000000003, 0xfffffffe)
    expected: 0x00000000000000000000000000000000 0x00000000000000000000000000000000
    actual:   0x00000000000000000000000000000001 0x00000000000000000000000000000001

Caused by:
    ulp 1 > 0

Testing with the new (unreleased) version of Rug returns 0x00000000000000000000000000000001, so I will just wait for that release.

@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch 2 times, most recently from 7394ee7 to ca979f9 Compare January 25, 2025 01:25
@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch from ca979f9 to 946f6ec Compare January 25, 2025 01:27
@tgross35
Copy link
Contributor Author

f16 needs way more rounds than the other operations, I am going to check if there is a better algorithm.

@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch from 9d32668 to 9fe11d3 Compare January 25, 2025 02:02
Use the generic `scalbn` to provide `f16` and `f128` versions, which
also work for `ldexp`.
@tgross35 tgross35 force-pushed the tgross35/f16-f128-scalbn branch from 9fe11d3 to 80b1394 Compare January 30, 2025 06:00
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.

1 participant