Skip to content

fix: handle division-by-zero in calculator#149

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

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

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Added a guard in src/calculator.ts divide() that throws an Error("Division by zero is not allowed") when the divisor is zero, preventing Infinity/NaN results.
  • Added tests in test/calculator.test.ts verifying 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 sentinel value).
  • All existing tests continue to pass (verified: 5/5 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