calculator icon indicating copy to clipboard operation
calculator copied to clipboard

Standard and Scientific modes allow multiple zeros to be prefixed

Open fjoshuajr opened this issue 7 years ago • 5 comments

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

  1. Enable 'Standard' or 'Scientific' mode.
  2. Click the decimal point '.'
  3. Press the backspace key to remove the decimal point.
  4. Press the zero key multiple times. Other digits can be pressed too.
  5. 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

image

image

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.

fjoshuajr avatar Nov 21 '19 20:11 fjoshuajr

This is your friendly Microsoft Issue Bot. I've seen this issue come in and have gone to tell a human about it.

MicrosoftIssueBot avatar Nov 21 '19 20:11 MicrosoftIssueBot

Nice catch! Thanks for the detailed bug report.

grochocki avatar Nov 22 '19 02:11 grochocki

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 😀

fjoshuajr avatar Nov 22 '19 10:11 fjoshuajr

Of course! Thanks for taking a look.

grochocki avatar Nov 22 '19 17:11 grochocki

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.

gsfreema avatar Nov 22 '19 17:11 gsfreema