Adds Exponenciation
Hello Andrés, are you still interested in finishing this PR after all this time? If you are, more work has to be done. Namely:
- Read the specification at https://speleotrove.com/decimal/daops.html#refpower
- Implement the operation according to the specification (e.g.,
0^0is illegal) - Implement standard test cases and make sure they all pass
You'll need #75 for steps 2. and 3. In particular, you'll need fix(::Decimal) to take care of rounding, and you'll need scripts/dectest.jl to generate the standardized tests. I'll merge that PR in a few days.
I can provide assistance if needed.
i will wait for #75 to be merged then. After that, i can take another jab at the implementation haha
The PR has been merged.
You can get the standard test suite here: https://speleotrove.com/decimal/dectest.zip
Then, you need to add support for power tests in the scripts/dectest.jl script. That means to add a new branch to the print_operation function and implement print_power(io, x, y). You should be able to call
julia scripts/dectest.jl Power PATH_TO_DECTESTS/power.decTest test/dectests/test_power.jl
julia scripts/dectest.jl PowerSqrt PATH_TO_DECTESTS/powersqrt.decTest test/dectests/test_powersqrt.jl
This will create two test files, test/dectests/test_power.jl and test/dectests/test_powersqrt.jl, which you should include in test/runtests.jl.
After these steps, you'll have a pretty good test coverage for the power operation. Your implementation should successfully pass all the tests. When in doubt, you can check an implementation in Python.
Please, make sure to use comments to explain all tricky, non-trivial parts of your code, so that we can understand them in the future.