mamrhein / fpdec.rs Goto Github PK
View Code? Open in Web Editor NEWFast implementation of Decimal fixed-point arithmetics
License: BSD 3-Clause "New" or "Revised" License
Fast implementation of Decimal fixed-point arithmetics
License: BSD 3-Clause "New" or "Revised" License
Does fpdec lib has any conversion to another type(isize, u8, i16)?
-1e-22
is just small enough to trigger the crash
Converting a Decimal with absolute value less than 1 and significant bits larger than the number of mantissa bits of the target type causes the function 'n_signif_bits' to be called with parameter 0, which leads to the 'subtract with overflow ' panic.
f64::from(Decimal::new_raw(9802266554071127_i128, 16)) gives 0.9802266554071128 instead of 0.9802266554071127.
Converting from certain f64 values results in a left-shift overflow during conversion
The value 113078212145816600000000000000000000000000000000000000000000000000000000000.0
is one such example
The debug output implementation seems broken. Here's a minimal reproducible example
This small test program:
fn main() {
let decimal = fpdec::Decimal::new_raw(-42472286074876, 18);
println!("{}", decimal);
println!("{:?}", decimal);
}
Gives the output:
-0.000042472286074876
Dec!(-1.999957527713925124)
fpdec 0.8.0
rustc 1.72.0-nightly (04075b320 2023-06-22)
The inability to convert between rust numeric primitives and Decimal is a limitation I am running into
I am currently converting the decimal to a string and re-parsing it, which is far from ideal
An implementation of Hash would also simplify things on my end
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!
To exponentiate fixed-p values I currently have to drop both operands to float first, checked_pow would round out the available set of checked operators
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.