Decimals.jl icon indicating copy to clipboard operation
Decimals.jl copied to clipboard

Adds Exponenciation

Open longemen3000 opened this issue 6 years ago • 3 comments

longemen3000 avatar May 06 '19 19:05 longemen3000

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:

  1. Read the specification at https://speleotrove.com/decimal/daops.html#refpower
  2. Implement the operation according to the specification (e.g., 0^0 is illegal)
  3. 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.

barucden avatar Nov 01 '24 16:11 barucden

i will wait for #75 to be merged then. After that, i can take another jab at the implementation haha

longemen3000 avatar Nov 01 '24 19:11 longemen3000

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.

barucden avatar Nov 03 '24 14:11 barucden