Coder Social home page Coder Social logo

Comments (3)

schungx avatar schungx commented on September 25, 2024

You only get 28 digits of precision for this type because it is based on 96 bits. You cannot get more precision than 28.

from rust-decimal.

paupino avatar paupino commented on September 25, 2024

Hi @danhuiwang,

As @schungx points out - this library only supports 28 digits of precision at present. When parsing a string it tries to round the value (safely) to fit into the provided format - which in this case drops the last two digits of precision. If you want to avoid this implicit rounding you can instead use from_str_exact which will instead error if it can't parse the entire decimal.

A maximum scale of 28 is a hard limit of this library at present - it is something I'd like to investigate with version 2 of this library using const generics however this requires a few more nightly features to be stabilized first.

If you need a library with a larger precision then I believe you can utilize bigdecimal. This uses a BigInteger behind the scenes which can grow in size accordingly.

Let me know if you have any further questions!

from rust-decimal.

Tony-Samuels avatar Tony-Samuels commented on September 25, 2024

A maximum scale of 28 is a hard limit of this library at present - it is something I'd like to investigate with version 2 of this library using const generics however this requires a few more nightly features to be stabilized first.

If this comes out, it is likely to be as a new crate, at least initially. Closing this out for now.

from rust-decimal.

Related Issues (20)

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.