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

Allow decimal powers and improve rounding algorithm. #23

Merged
merged 9 commits into from
May 11, 2024
Merged

Conversation

ZCG-coder
Copy link
Owner

@ZCG-coder ZCG-coder commented May 10, 2024

1. Add support for decimal powers

For power expressions in the form of $n^{ \frac{a}{b} }$, it can be simplified into

$$ \sqrt[b]{n^a} $$

Also, the expression $\sqrt[\frac{a}{b}]{n}$ can be transformed into

$$ \sqrt[a]{n^b} $$

With the root component, it is possible to perform the above-mentioned operations. First, the number is converted into a fraction, and power/root operations are performed to obtain the result.

2. Improve rounding algorithm

The roundOff() method does not correctly round numbers. This PR introduces a new, reworked algorithm to allow rounding off to any desired precision.

3. Introducing printers

The old Unicode-based printing is not flexible enough to display nested operations. It is time to switch to a SymPy-like printer system.

Tasks:

  • Add support for decimal powers.
  • Add support for decimal roots.
  • Add tests.

@ZCG-coder ZCG-coder added T-Feature Type - New feature or request C-C++ Code - Pull requests that update C++ code. labels May 10, 2024
@ZCG-coder ZCG-coder added this to the First Release milestone May 10, 2024
@ZCG-coder ZCG-coder self-assigned this May 10, 2024
ZCG-coder added 4 commits May 10, 2024 18:12
- Introducing printers, a new way to format the output.
- root.cpp:83 Should be Fraction(number) instead.
ZCG-coder added 2 commits May 11, 2024 20:50
- In rounding.cpp: Reworked rounding algorithm.
- Added tests for power with a decimal exponent.
- Added tests for root with a decimal index.
@ZCG-coder ZCG-coder requested review from 813ethan and Noob9331 May 11, 2024 15:41
@ZCG-coder ZCG-coder changed the title Allow decimal powers. Allow decimal powers and improve rounding algorithm. May 11, 2024
@ZCG-coder ZCG-coder added the T-Bug Type - Bug and unexpected behavior. label May 11, 2024
813ethan

This comment was marked as resolved.

@ZCG-coder ZCG-coder removed the request for review from Noob9331 May 11, 2024 15:52
@ZCG-coder ZCG-coder merged commit b715de8 into main May 11, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-C++ Code - Pull requests that update C++ code. T-Bug Type - Bug and unexpected behavior. T-Feature Type - New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants