Skip to content

fix: handle division by zero in calculator#148

Open
quantcode-agent[bot] wants to merge 1 commit intomainfrom
quantcode/job-job-f0d58982
Open

fix: handle division by zero in calculator#148
quantcode-agent[bot] wants to merge 1 commit intomainfrom
quantcode/job-job-f0d58982

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Fixed division-by-zero bug in src/calculator.ts by throwing an Error with message "Division by zero is not allowed" when the divisor is zero
  • Added test coverage for both normal division and the division-by-zero error case

Assumptions

  • Throwing an Error is the appropriate behavior for division by zero (rather than returning a special value like null or NaN)
  • The error message "Division by zero is not allowed" is descriptive enough for consumers

Testing

All 5 tests pass including the new division-by-zero test case.

Throw an Error with descriptive message when dividing by zero instead of
returning Infinity. Added test coverage for the division-by-zero case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants