Skip to content

fix: handle division by zero in calculator#140

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

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

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Fixed division-by-zero bug in src/calculator.ts by throwing an Error("Division by zero") when the divisor is 0
  • Added tests in test/calculator.test.ts verifying both normal division and the zero-guard behavior

Assumptions

  • Throwing an error is the appropriate behavior for division by zero (rather than returning NaN, Infinity, or a result object)
  • All existing tests continue to pass (bun test — 5 tests passing)

Throw an error when dividing by zero instead of returning Infinity.
Added tests to verify the division-by-zero guard.
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