jsbean / ArithmeticTools

Basic arithmetic types and operations
MIT License
3 stars 0 forks source link

De-optionalize Rational and Fraction respelling(numerator:/denominator:) #115

Closed mossheim closed 7 years ago

mossheim commented 7 years ago

Fixes #110. Also does math using doubles rather than floats.

Also, respelling(denominator:) now guards against the case where numerator==0.

codecov-io commented 7 years ago

Codecov Report

Merging #115 into master will increase coverage by 0.09%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #115      +/-   ##
==========================================
+ Coverage   87.74%   87.83%   +0.09%     
==========================================
  Files          50       50              
  Lines        1452     1447       -5     
==========================================
- Hits         1274     1271       -3     
+ Misses        178      176       -2
Impacted Files Coverage Δ
ArithmeticTools/Rational.swift 69.44% <100%> (+2.15%) :arrow_up:
ArithmeticToolsTests/RationalTests.swift 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update cbb65aa...e365ae9. Read the comment docs.

mossheim commented 7 years ago

We might want to change the contract/documentation of this function... maybe the asserts should be preconditions? Technically if you're in release mode and the asserts are gone you could get a value that isn't equal to the original Rational. So maybe we write in the contract that you need to be sure you can represent it with that numerator/denominator before proceeding?