Comments (3)
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.
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.
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)
- Support for mongo HOT 2
- To f64 losing accuracy for `100000.000000000000000000` HOT 1
- Scaling string representation differs from dividing by 10^x HOT 4
- too rubbish to called rust decimal HOT 3
- checked_powd takes exponentially long time to complete HOT 6
- Scale changes unexpectedly after operations HOT 3
- 1.34.0 breaks with cyclic dependency when installed with "macros" feature HOT 4
- Deserializing `Decimal`s from Postgres using the `db-postgres` feature can lead to invalid `Decimal` instances HOT 4
- Bug: not 128bit aligned with `repr-c` feature HOT 3
- Return error rather than panic in `FromSql` when overflow HOT 1
- Bug: Decimal::from_sql incorrectly transforms Postgres NaN to 0 HOT 1
- rust_decimal_macros 1.35.0 not on crates.io (Or: Error in Documentation) HOT 2
- Diesel1 feature is breaking the build
- Unsigned Decimal? HOT 4
- bug: `abs_sub` does not compute the difference HOT 1
- Provide handy constants HOT 1
- Pow overflows HOT 1
- latest arrayvec versions fail build (>0.7.4): "type annotation needed" HOT 4
- Compilation with `serde-str` feature is broken HOT 6
- Add documentation for Decimal::to_u<xx>(&self) methods HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-decimal.