Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Bourdeaa wants to merge1 commit intophishman3579:master
base:master
Choose a base branch
Loading
fromBourdeaa:DivisorFix

Conversation

@Bourdeaa
Copy link

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.

publicclassDivision {

publicstaticfinallongdivision(inta,intb) {

Copy link
Author

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) {
Copy link
Author

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) {
Copy link
Author

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) {
Copy link
Author

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) {
Copy link
Author

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);

Copy link
Author

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.

Copy link
Author

@BourdeaaBourdeaa left a 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

Copy link
Author

@BourdeaaBourdeaa left a comment

Choose a reason for hiding this comment

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

Review looks great.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@Bourdeaa

[8]ページ先頭

©2009-2025 Movatter.jp