- Notifications
You must be signed in to change notification settings - Fork1.9k
Fixed Dividing by Zero errors#251
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…s to throw exception if divisor is 0
| publicclassDivision { | ||
| publicstaticfinallongdivision(inta,intb) { | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The method will throw an exception by ensuring the value of b before the result "long" is calculated avoiding unexpected results.
| intabsA =Math.abs(a); | ||
| intabsB =Math.abs(b); | ||
| if (b ==0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The method will throw an exception by ensuring the value of b before the result "long" is calculated avoiding unexpected results.
| intabsA =Math.abs(a); | ||
| intabsB =Math.abs(b); | ||
| if (b ==0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The method will throw an exception by ensuring the value of b before the result "long" is calculated avoiding unexpected results.
| intabsA =Math.abs(a); | ||
| intabsB =Math.abs(b); | ||
| if (b ==0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The method will throw an exception by ensuring the value of b before the result "long" is calculated avoiding unexpected results.
| intabsB =Math.abs(b); | ||
| inttempA,tempB,counter; | ||
| if (b ==0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The method will throw an exception by ensuring the value of b before the result "long" is calculated avoiding unexpected results.
| publicstaticfinallongdivisionUsingLogs(inta,intb) { | ||
| longabsA =Math.abs(a); | ||
| longabsB =Math.abs(b); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The method will throw an exception by ensuring the value of b before the result "long" is calculated avoiding unexpected results.
Bourdeaa left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Please note comments for each change in the PR
Bourdeaa left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Review looks great.
This feature adds illegalArgumentException handling for divisors of 0. This exception is thrown for each method regardless of how the division is obtained. The method of using Exceptions is useful as future development allows for change in the exception handling, futureproofing the code to change how we want to handle division by 0 errors.