Open rdrpenguin04 opened 1 year ago
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.
Nevermind. f128
somehow has even less features.
Agh.
rust-lang/rfcs#2629
Nearly there: rust-lang/rust#127027
This will be a nightly feature, but I'm okay with that.
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).
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/.
Ooh, that's actually a really good point; thank you! :D
f64
has run into overlow/underflow errors with my homework; advising switching toDecimal128
at suggestion of an LC member.