Giter Site home page Giter Site logo

mamrhein / fpdec.rs Goto Github PK

View Code? Open in Web Editor NEW
17.0 17.0 4.0 296 KB

Fast implementation of Decimal fixed-point arithmetics

License: BSD 3-Clause "New" or "Revised" License

Rust 99.97% Shell 0.03%
arithmetic decimal fixed-point mathematics number rust

fpdec.rs's People

Contributors

den-mentiei avatar mamrhein avatar roms1383 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fpdec.rs's Issues

'subtract with overflow ' panic in fn into_float::n_signif_bits

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.

lshift overflow in from_float.rs:217

Converting from certain f64 values results in a left-shift overflow during conversion
The value 113078212145816600000000000000000000000000000000000000000000000000000000000.0 is one such example

Debug output gives crazy result

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)

Requesting implementations for Hash, and TryInto<i/u/f/*>

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

increasing precision

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!

Feature request: checked_pow

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.