Break My Calculator!

I’m trying to build all my projects with React+Redux to practice because I’m learning them. If you could please take a look at my calculator and break it, that’d be great! Because I’m sure forgot some edge cases somehow and I’d like to fix it. All I know is that the code I wrote is absolutely horrible hides in a corner :flushed:

Thanks! :smiley:


Broken: Pressing the following keys:

1 / 7 = * 7 should be 1 and not 1.003

  • Not really breaking it but, If I click an operator and change my mind I can not click a different operator sequentially, instead I have to CE and then click another operator
  • The following sequence of operations gives a div/0 error when it shouldn’t:

– I like the division by zero dance, and nice job overall

@RandellDawson that is technically an error, you are right, I went back to my old calculator and I also actually used a similar rounding off technique as @ncaron has and I get the same erroneous result due to rounding off.

Thank you both!

1 / 7 = * 7 is because of the rounding on the first operation, not sure if I will fix this one yet.

6+9-CE/9 is weird, it was working before but it seems like it does the same thing anytime I press CE on an operator. I’ll have to fix this, thanks!

EDIT: @Dereje1 I think I fixed both issues. :smiley: