And here's another calculator. Hopefully as foolproof as I think

And here's another calculator. Hopefully as foolproof as I think
0

#1

Here it is

If anybody has a play with it and notices any weird behaviors (other than, uhm, design decision of always appending to what’s on display instead of clearing - not like any real calculator I’ve ever seen), do let me know. I think I covered all the bases, so it should not be possible to input and try to calculate something arithmetically nonsensical, but I most likely missed something anyway :wink:


#2

HI, @foresterr. The only weird behavior I found is when I filled the calculator with digits then multiplied by 10. The result is in exponential notation that overflows.


#3

Thanks @kevcomedia ! That actually didn’t have anything to do with multiplication - after the display is filled with numbers, my calculator ignores all further input before you make space. But I had a problem with how I was formatting numbers for display (you’d get the same error after just typing a long number and pressing = …), which I fixed.


#4

I finished mine yesterday and had some positive critics which I really appreciated, so here’s my feedback to you:

  1. Someone pointed out to me the .x calculations. I mean that it would look nicer to make them 0.x instead of .x . I thought he was right, so I fixed it. Sure looks better (pro) that way.
  2. Same goes for the results. It’s a bit awkward to see a .xxxx reslut instead of 0.xxxx
    3.Memory handling doesn’t function like it should.
    Just try 25 M+ 3 MR + MR (it should give 28 as result, but it doesn’t)
    Furthermore, MC doesn’t seem to work either (or I just don’t get it).
  3. 0 divided by .9 doesn’t give 0, just stays .9
  4. I can add multiple floating points to a number

#5

Thanks for taking a look! I’ll try to pay it forward sometime :slight_smile:
Regarding your feedback:

  1. I actually like the no-leading-zero presentation, so I think I’ll keep it. I already had some code to remove the leading zero from result (it is there by default :smiley: ), now for the sake of consistency I added even more of it so that inputting a decimal dot would “eat” a leading zero.
  2. Same as 1.
  3. MC clears the memory (sets to 0, only visible result is the M icon disappearing), MR restores memory content to the screen if it’s not 0 (but in the same way as all input works in my calculator - it’s appended to current input, it does not replace it, and does not trigger evaluation), M+ evaluates current input and adds it to memory, M- does the same but subtracts. I think I’ll make M+ and M- clear the current input as well.
  4. To make it less confusing, I removed the initial 0 displayed. Should be more clear now that what’s get evaluated is just what’s on display, there is no invisible cached value anywhere (unless using the memory :wink: ). Before, this initial 0 was always discarded on user input anyway, so it didn’t make much sense.
  5. Dammit how did I miss this one? Fixed! :slight_smile:

All in all I realise this calculator is a little weird, but some of that weirdness is intended. Believe it or not :sweat_smile:


#6

Maybe this is intentional, but I don’t really like how division by 0 is handled. Then you have 0 on the screen with little “e” at the other corner - this is quite confusing (imagine if a child would be using this calculator, this might give him a wrong impression that dividing by 0 equals 0). And after that it won’t let to do any calculations until you refresh the screen with C button.
Also when you get your result, for example you do 2+5 and get 7 and if then you just press any number, for example 9, it will become 79. I think ideally it should be like in windows default calculator - if you get result and press any number, it just automatically clears the result and starts with the new number (will be just 9 in the example).

But I really like your design - it’s simple and pleasant to my eye, and with normal calculations (when I don’t try to break it intentionally) your calculator works fine.


#7

Point taken about displaying 0 on errors. Now it won’t change the display to 0 when the calculation results in error, it will just display the E and lock up :stuck_out_tongue:

I’m keeping the “E” and locking up because it’s amusing to me for nostalgia reasons. Here we have all this brilliant technology, and I what I do is simulate irritating behaviours that I observed 20 years ago with real pocket calculators :wink:

About the append-to-display behaviour, you are another person who finds it too weird, so I changed it. Now typing numbers after pressing = will clear the display first. If you press arithmetic sign before adding more numbers, it will be appended and then work as before. MR will also clear the display unless it can be appended after an arithmetic sign.

And thanks for finding my design nice, this is actually the first time I built it from the ground up - before I’d use Bootstrap for minimum possible effort. Which was nice, but this is supposed to be a learning experience!
(although, in this case it was mostly learning experience because my code became a tangle at some point and made me think harder about OOP and how to structure it properly. Next project, I guess :sweat_smile: )