Standard and Scientific modes allow multiple zeros to be prefixed
Describe the bug
When using the standard or scientific mode, the calculator allows multiple zeros to be prefixed inside the input field. While it doesn't change the calculation results, this is weird behavior.
Steps To Reproduce
- Enable 'Standard' or 'Scientific' mode.
- Click the decimal point '.'
- Press the backspace key to remove the decimal point.
- Press the zero key multiple times. Other digits can be pressed too.
- See error.
Expected behavior
After removing the decimal point (step 3 above), the initial zero should be replaced with the first non-zero digit typed.
Screenshots


Device and Application Information
- OS Build: 10.0.18362.0
- Architecture: x64
- Application Version: 10.1908.0.0
- Region: en-US
- Dev Version Installed: False
Additional context
N/A
Requested Assignment
I'm just reporting this problem. I don't want to fix it.
This is your friendly Microsoft Issue Bot. I've seen this issue come in and have gone to tell a human about it.
Nice catch! Thanks for the detailed bug report.
Cool. Actually, I would like to work on this if that's ok with you @grochocki — it's an opportunity for me to get my feet wet on a c++ codebase 😀
Of course! Thanks for taking a look.
I looked at this a bit. My guess is that the fix will be around here.
https://github.com/microsoft/calculator/blob/6e2b82c8bfebf94643c395d8cab7f6bbc9cb2db7/src/CalcManager/CEngine/CalcInput.cpp#L240
When you press 0, it checks the CalcNumSec::value string to see if it is empty or not. Right now, when you press . when there is a 0 in the calculator, that string becomes 0.. The code linked above will pop that ., but it leaves the 0 behind so future presses of 0 sees that there is an existing value and will append. You could probably check if the result of popping the decimal is just 0, then clear that too.