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

Added implementation of Not_Equal_To #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions big-int/src/operators/not_equal_to.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,20 @@

namespace libbig {

bool largeInt:: operator != (const largeInt& z) {
if(this->sign != z.sign) {
return true;
}
if (this->number.length() != z.number.length()) {
return true;
}
for(int i = 0; i < this->number.length(); i++) {
if (this->number[i] != z.number[i]) {
return true;
}
}
return false;
}
Comment on lines +35 to +48
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this have to be so complex? Operator == is already overloaded.

bool largeInt:: operator != (const largeInt z) {
return !(*this == z);
}

This much code should be fine. Plus it will always be in sync with == operator.

Copy link
Owner

Choose a reason for hiding this comment

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

actually this PR was made before the overloading of == operator.
i was thiking to request changes on this
thanks @ufrshubham for pointing out

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, that makes sense.


} // namespace libbig