Comments (3)
I'll look into experimenting with a few options over the next few days or so. A good .pow function would look something like
fn pow(left: Fraction, right: Fraction) -> Fraction {
let exp = right.numer().unwrap().clone();
let root = right.denom().unwrap().clone();
// Insert code here where result = nthroot(left^exponent, root)
return result
}
from fraction.
Hi @Gip-Gip, thank you for your interest and your support!
Regarding pow
, I feel like we may consider falling back to num-rational pow implementation. Fraction is built on top of Rational type already, so this may be the eastiest path forward
Not too sure about sqrt
. That feels somewhat more challenging. I guess you may have a real-world problem on your hands, so we'd be happy to consider a way that would solve your current challenge.
One of the primary goals of this library is to provide lossless math, so I am not too sure if an approximation would follow that direction. However, if we explicitly call that out in the function name (e.g. sqrt_approx
), I think that should be totally alright.
from fraction.
I've been working on a crate heavily building on top of the fraction crate for exact arithmetic. the relevant code is here
first handle special cases such as infinity or nan, then do the calculation. It's inside match statements, but should be quite copy-pasteable into this crate.
from fraction.
Related Issues (20)
- Add better unicode support (Fraction slash/division slash) HOT 8
- eligible for funding via thanks.dev HOT 2
- Completing implemention of `identities` module from `num_traits` HOT 3
- Upgrade postgresql support to 0.18.x
- FromStr trait support + Parse fractions HOT 4
- How to convert to `f32` and `f64` numeric types HOT 1
- Serde support? HOT 2
- Fraction::from_str can fail with overflow if fractional part ends with too many zeroes HOT 3
- Weird huge values when getting the denominator of a fraction HOT 9
- Serialization support for DynaInt HOT 1
- Error: trait bounds other than `Sized` on const fn parameters are unstable HOT 2
- What does it mean that a value cannot be represented by `Ratio<T>`? HOT 2
- Fraction ceil and floor round negative fraction "the wrong way" HOT 1
- how do you conver a GenericFraction into a float? HOT 5
- Is there a list of methods that floats have that aren't impled for fractions HOT 2
- Do not simplify fractions HOT 1
- How should I handle consts? HOT 1
- Add From for f64 and f32 HOT 6
- Trait bounds were not satisfied with nalgebra 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 fraction.