Visitar URL original
Fix continued fraction precision by ryley05 · Pull Request #15743 · TheAlgorithms/Python · GitHub
Skip to content

Fix continued fraction precision - #15743

Closed
ryley05 wants to merge 2 commits into
TheAlgorithms:masterfrom
ryley05:fix_continued-fraction-precision
Closed

ryley05 wants to merge 2 commits into
TheAlgorithms:masterfrom
ryley05:fix_continued-fraction-precision

Conversation

@ryley05

@ryley05 ryley05 commented Nov 13, 2026

Copy link
Copy Markdown

Describe your change

  • Fix a bug or typo in an existing algorithm.
  • Add or change doctests.
  • Add an algorithm.
  • Documentation change.

This change fixes a precision issue in maths/continued_fraction.py. The previous implementation used floor(numerator / denominator), which converted large integers to floating-point numbers and could produce inaccurate results or overflow.

The implementation now uses integer floor division (numerator // denominator), avoiding floating-point conversion while preserving the intended behavior.

Two regression doctests were added to cover large integer inputs, including values that exceed the range of normal floating-point representation.

Issue: Fixes #15655

Checklist

  • I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • This pull request resolves an open issue and includes the closing keyword and issue number above.

@algorithms-keeper algorithms-keeper Bot added the awaiting reviews This PR is ready to be reviewed label Nov 13, 2026
@algorithms-keeper

Copy link
Copy Markdown

Closing this pull request as invalid

@ryley05, this pull request is being closed as the files submitted contains an invalid extension. This repository only accepts Python algorithms. Please read the Contributing guidelines first.

Invalid files in this pull request: Agent/.gitignore

@algorithms-keeper algorithms-keeper Bot removed the awaiting reviews This PR is ready to be reviewed label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

continued_fraction uses float division, producing invalid terms for large integers and raising OverflowError

1 participant