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

Better precision #4

Open
rdrpenguin04 opened this issue Apr 18, 2023 · 7 comments
Open

Better precision #4

rdrpenguin04 opened this issue Apr 18, 2023 · 7 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@rdrpenguin04
Copy link
Owner

f64 has run into overlow/underflow errors with my homework; advising switching to Decimal128 at suggestion of an LC member.

@rdrpenguin04 rdrpenguin04 self-assigned this Apr 18, 2023
@rdrpenguin04
Copy link
Owner Author

The decimal crate's d128 looks like a promising candidate. It's missing a few things that mathy-notes needs, like trig, particularly inverse trig, mathematical constants, and sqrt and co (but pow exists).

The dec crate seems to very possibly use the same library, and it's maintained, but it's also woefully under-featured, missing all of the above, and some features are tucked away in strange places.

The fraction crate is impressive and could be useful in the future, but it doesn't solve the feature problem; rather, it makes the problem significantly worse by having to work around fractions being represented perfectly. The infrastructure is also incredibly bulky.

The best solution I see for now is to use f128 (uses GCC's libquadmath) and roll our own in the future.

@rdrpenguin04
Copy link
Owner Author

Nevermind. f128 somehow has even less features.

Agh.

@rdrpenguin04
Copy link
Owner Author

rust-lang/rfcs#2629

@rdrpenguin04 rdrpenguin04 added the enhancement New feature or request label Apr 19, 2023
@rdrpenguin04 rdrpenguin04 added the help wanted Extra attention is needed label Oct 17, 2023
@rdrpenguin04
Copy link
Owner Author

Nearly there: rust-lang/rust#127027

This will be a nightly feature, but I'm okay with that.

@tgross35
Copy link

Nearly there: rust-lang/rust#127027

This will be a nightly feature, but I'm okay with that.

As a pretty important note, the math functions are completely broken on x86 due to LLVM bugs :( (LLVM incorrectly calls the long double functions on x86, which are x87 80-bit floats and not binary128).

Aarch64 works alright though!

(Just came across this since I saw it crosslinked in the PR).

@tgross35
Copy link

tgross35 commented Jul 28, 2024

That being said, depending on what your use case is and if you may need more than 128 bits of precision, something like an arbitrary-precision library may be a better fit https://docs.rs/rug/latest/rug/.

@rdrpenguin04
Copy link
Owner Author

Ooh, that's actually a really good point; thank you! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants