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

Decimal to rational number convertion #2

Open
varsill opened this issue Sep 6, 2019 · 0 comments
Open

Decimal to rational number convertion #2

varsill opened this issue Sep 6, 2019 · 0 comments

Comments

@varsill
Copy link
Owner

varsill commented Sep 6, 2019

The conversion between decimal numbers (used in _createRational1() ), stored as floating point variables and rational numbers has been implemented in the easiest way possible - the numerator is get by multiplying the float number by some fixed number with value 10^n while the denominator is simplu 10^n. That may lead to errors while converting big numbers (variables can easly overflow) as well as might not be accurate - we want to be able to convert 0.33333333333 to 1/3. There is a need to implement the conversion based on the theory of continued fractions.

Function to be rewritten: void approximate(double x, int* nominator, int* denominator)

https://stackoverflow.com/questions/95727/how-to-convert-floats-to-human-readable-fractions

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

1 participant