Skip to content

fix: handle division by zero in calculator#137

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

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

Conversation

@quantcode-agent
Copy link
Copy Markdown

Summary

  • Added a guard in src/calculator.ts to throw an error ("Cannot divide by zero") when the divisor is zero, instead of returning Infinity
  • Added tests in test/calculator.test.ts to verify both normal division and the zero-divisor error case

Assumptions

  • The appropriate behavior for division by zero is to throw an Error rather than returning a special value
  • All existing tests continue to pass (5/5 passing)

Throw an error when dividing by zero instead of returning Infinity.
Added test to verify the error is thrown correctly.
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