Comments (4)
Unfortunately the underlying API does not support these ops so it is not easy to add. If you can provide implementations I would be happy to review them.
That aside why do you think d128 is going to be accurate? Is there something specific about sin/cos/tan that make them more accurate when arithmetic is done in decimal arithmetic and not binary? Perhaps you are looking for an arbitrary precision library?
from decimal.
I've already gone ahead and switched the calculate crate to using d128
, instead of f64
, and it is more accurate. 0.1 * 0.1 actually equals 0.01, and not 0.010000000000000002. The bigdecimal
crate is much further behind this one, so it's not an option at this time.
from decimal.
Decimal floating point suffers from the same rounding issues as binary floating point. It's just that the decimal rounding issues tend to line up with how humans do things by hand. This doesn't mean that decimal floating point doesn't have surprising results. For example:
println!("{}", d128!(3.0) * (d128!(1.0) / d128!(3.0)));
outputs 0.9999999999999999999999999999999999
.
from decimal.
I think trigonometric functions would be best implemented in some other crate, since exactly what is required is strongly dependent on the application's needs for accuracy. It seems better if this crate remains a fairly thin binding to decNumber
.
I've been looking into this for one of my own applications but haven't arrived at any particular conclusions for the best way to implement trig functions in terms of d128 (I am by no means an expert numeric analyst!). A Taylor series approximation is pretty easy to implement but might be very costly, and I suspect a different polynomial approximation would perform better. Iterative approximation (CORDIC) seems decent but I suspect it's not significantly more performant than implementations that are expressed in terms of multiplication because this library can take advantage of hardware multipliers to a certain degree.
from decimal.
Related Issues (20)
- guidance on writing f64, f32 conversion HOT 2
- Error compiling library on Raspbian
- Incorrect formatting HOT 2
- quantize() with quantum >1 doesn't work properly
- compilation fails on ppc64le, s390x, aarch64, armv7hl HOT 4
- unsigned d128
- Consider to move the crait in `rust_num`
- sqrt method HOT 1
- remove rustc-serialize HOT 4
- d128::from_str() returns Ok on non valid inputs HOT 1
- UB and usage of deprecated function HOT 10
- `from_str` panic HOT 2
- status of the project HOT 2
- Two d128 values are equal, but their hashes aren't
- d128 to integer value HOT 2
- `exp` causes infinite loop
- how to add this library with my own C program
- const literals? HOT 3
- Provide bindings to `decNumberRescale`
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 decimal.