mamrhein / fpdec.rs

Fast implementation of Decimal fixed-point arithmetics
BSD 3-Clause "New" or "Revised" License
17 stars 4 forks source link

increasing precision #1

Closed MarkSwanson closed 2 years ago

MarkSwanson commented 2 years ago

I'd like to use this library with the 'quantities' crate to do some quantum mechanics work. Planck's constant is 6.62607015 × 10−34 , so I'd like about 42 digits of precision.

Is forking this library the only way to increase the precision? (Fork and adjust the MAX_N_FRAC_DIGITS constant defined here: fpdec-core/src/lib.rs)

Thanks!

MarkSwanson commented 2 years ago

Fyi fp64 has an accuracy ~= 16 digits after the decimal.

mamrhein commented 2 years ago

fpdec.rs uses an i128 to store the coefficient. This gives room for 38 decimal digits. 42 digits is definitely out of scope.

mamrhein commented 2 years ago

The original requirement is targeted at the quantities.rs crate. That crate can use different types for the numerical part of a quantity value, so maybe the solution could be another numerical type as optional dependency. Please see there.

mamrhein commented 2 years ago

Closing this as "will not implement".