Skip to content

fix: handle division by zero in calculator#135

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

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

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Added a guard in src/calculator.ts divide() function that throws an Error("Division by zero") when the divisor is zero, instead of silently returning Infinity
  • Added test coverage in test/calculator.test.ts verifying both normal division and the zero-divisor error case

Assumptions

  • Throwing an error is the appropriate behavior for division by zero (rather than returning null/NaN/Infinity)
  • The error message "Division by zero" is sufficient for consumers to identify the issue

All 5 tests pass.

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