Skip to content

Divide by zero allows operations with Infinity #2

@jesseparent

Description

@jesseparent

Dividing by zero displays the Infinity symbol, which is arguably correct. However, the user can then select an operation (e.g. minus ("-") ) and the calculator allows the user to perform operations with Infinity. This may be undesired. One possible solution is to clear out the state if the user attempts to do this by adding a check on the currentOperand in the CHOOSE_OPERATION action to clear the state if currentOperand is Infinity

For example, add on line 46:

if (state.currentOperand == Number.POSITIVE_INFINITY) return {};

STEPS TO REPRODUCE
Press 3
Press ÷
Press 0
Press =
Press +
Press 9
Press =

EXPECTED RESULT
The calculator displays 9, waiting for an operation to be done with that number

ACTUAL RESULT
The calculator displays Infinity symbol because Infinity plus 9 is Infinity

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions