Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Square root of a Fraction? #12

Closed
MadsKirkFoged opened this issue Feb 7, 2022 · 4 comments
Closed

Square root of a Fraction? #12

MadsKirkFoged opened this issue Feb 7, 2022 · 4 comments

Comments

@MadsKirkFoged
Copy link
Contributor

Have a Square root function for a Fraction ever been on the table?
I need it from time to time.

Im guessing that it needs to be done in an iterative process and it might not be a easy as it sounds.
I could start working on it for this package if it would be accepted?

@danm-de
Copy link
Owner

danm-de commented Feb 7, 2022

Hi,

The reason there is no square-root function is simple: "I haven't needed it before". I think this feature would be a good addition to Fractions.

I (hope that I) have made the data type as efficient and fast as possible. That's why there are two methods to convert double -> Fraction. Looking at https://en.wikipedia.org/wiki/Methods_of_computing_square_roots I think the 'Heron' variant seems to be the most promising. Guess it would require some kind of 'max number of iterations' (precision) to prevent infinite loops.

@MadsKirkFoged
Copy link
Contributor Author

Sounds good that there is a simple reason for it not being there!

If you want to create it yourself that will be fine by me :-)
else I might take a look at it at a later time in the future.

@danm-de
Copy link
Owner

danm-de commented Feb 10, 2022 via email

@danm-de
Copy link
Owner

danm-de commented Feb 20, 2022

Pull request #13 merged, Nuget packages updated. Thanks for your contribution!

@danm-de danm-de closed this as completed Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants