 # Finished my calculator

Just finished my calculator. What do you guys think? http://codepen.io/hristijankiko/full/bwKgRz/

First off, well done. Yours follows the rules of arithmatic, i.e. 4 + 5 x 3 = 19, not 27.

One remark: do a reset just before you enter a new number after the = is pressed, because now there is some weird behaviour. Try it for yourself:

1. enter 4 + 5 x 3 =
2. result is 19.00
3. enter 4 + 5 x 3 again, the 4 is now appended to the 19.00
4. enter =
5. result now is 34.00

@hepabolu 19.004 + 5 x 3 = 19.004 + 15 = 34.004 and the number is rounded to 34.00 I think this is supposed to be 34?

I would expect 19.00 again.

More in detail:

calc1:

1. enter: 4 + 5 x 3 =
2. result = 19.00
3. enter: + 4 + 5 x 3 =
4. expected result = 38.00

actual result: 38.00 --> correct

calc2:

1. enter: 4 + 5 x 3 =
2. result = 19.00
3. enter: 4 + 5 x 3 =
4. expected result = 19.00

actual result: 34.00 -> not correct.

Just to be overly clear: in calc1 I did 1 calculation with a subtotal in between (step 2), in calc2 I actually did 2 calculations.

If I pressed AC between step 2 and step 3 in calc2 I get the expected result.

Your code appends the 4 to 19.00 (and turns it into 19.004) and continues with a second part of a calculation (like in calc1), but that’s not the intention of the user.

I was looking around for inspiration of the design and I stumbled upon this issue. This means I need to be extra alert to avoid the same issue to my own code. Oh yeah i should probably fix that.