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

GCD implementation using Euclid's algorithm #14

Closed
wants to merge 1 commit into from

Conversation

anandsit043
Copy link
Contributor

Modified files : BigInt.hpp and operators/binary_arithmetic.hpp
Please review

@codecov-io
Copy link

codecov-io commented Jan 2, 2018

Codecov Report

Merging #14 into master will decrease coverage by 3.8%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #14      +/-   ##
==========================================
- Coverage   98.94%   95.14%   -3.81%     
==========================================
  Files          12       12              
  Lines         475      494      +19     
==========================================
  Hits          470      470              
- Misses          5       24      +19
Impacted Files Coverage Δ
include/BigInt.hpp 100% <ø> (ø) ⬆️
include/operators/binary_arithmetic.hpp 89.78% <0%> (-7.9%) ⬇️

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 72a4c9f...392a87d. Read the comment docs.

Copy link
Owner

@faheel faheel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add unit tests for gcd() in test/functions/math.test.cpp.

// gcd:
friend BigInt gcd(const BigInt& num1, const BigInt& num2);
friend BigInt gcd(const BigInt& num1, const long long& num2);
friend BigInt gcd(const BigInt& num1, const std::string& num2);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GCD functions don't need to be friends of BigInt as they can be implemented without accessing the private members.


// Trivial Case handling
if(abs_num1.value == "0") return abs_num2;
else if (abs_num2.value == "0") return abs_num1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do:

if (abs_num1 == 0)
    return abs_num2;
if (abs_num2 == 0)
    return abs_num1;

@faheel faheel added the functions: math Math functions label Jan 3, 2018
@faheel
Copy link
Owner

faheel commented Jan 3, 2018

@anandsit043 You have made changes directly to your master branch which causes a problem reporting code coverage due to an issue with Codecov. So it would be great if you could follow the steps in the contribution guidelines to create a new branch, add your changes there, and send a new PR from that branch.

@faheel
Copy link
Owner

faheel commented Jan 3, 2018

Follow up in #15.

@faheel faheel closed this Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions: math Math functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants