microsoft / calculator

Windows Calculator: A simple yet powerful calculator that ships with Windows
MIT License
29.73k stars 5.39k forks source link

Clarify whether the application should allow users to paste numbers in scientific notation when using Standard mode or not #683

Closed rudyhuyn closed 5 years ago

rudyhuyn commented 5 years ago

Describe the bug

It is not clear if the calculator should allow users to paste expressions with scientific notations (E notation, for example 12e+10) when the calculator is in Standard mode.

Some unit tests and methods show that we should support it: https://github.com/microsoft/calculator/blob/41e2e975918c6838947e29a046778bd4d57feeee/src/CalculatorUnitTests/CopyPasteManagerTest.cpp#L133

https://github.com/microsoft/calculator/blob/41e2e975918c6838947e29a046778bd4d57feeee/src/CalcViewModel/Common/CopyPasteManager.cpp#L197

while other methods like CopyPasteManager::ExpressionRegExMatch don't accept them when the calculator is in Standard mode, making it impossible to paste a number in scientific notation.

Why we should allow it

Why we should not allow it

Steps To Reproduce

Expected behavior

Currently unknown

Device and Application Information**

Requested Assignment

If possible, I would like to fix this.

Bonus

If we allow users to do it, we should also decide if we want to allow them to copy these type of numbers with unit converters.

MicrosoftIssueBot commented 5 years ago

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

grochocki commented 5 years ago

Despite not having an exp button, I don't think we should be blocking folks unnecessarily from pasting in a valid number, so I think we should support pasting these values in both standard mode and in most converters.

Currency converter is an odd one, though, since that is not a domain where scientific notation is typically used. Are there other converters where scientific notation might not be appropriate?

rudyhuyn commented 5 years ago

I agree, we should not block users. I will fix ExpressionRegExMatch to allow these numbers asap.

For converters, I agree, I think we should allow it. I would probably never use scientific notation with the currency converter, but if someone wants to use this notation (💰), it's probably better to allow it and not treat this converter differently.

rudyhuyn commented 5 years ago

I ran some tests to assess the workload necessary to support:

Standard mode: StandardCalculatorViewModel + CalculatorManager already support this type of numbers, we simply need to modify some regular expressions in CopyPasteManager::ExpressionRegExMatch to support these numbers.

Unit Converter UnitConverterViewModel and UnitConverter don't support scientific notations. If we want to do it we need:

@grochocki if you are ok with that, I would recommend to fix the issue for the standard mode and create another task for converters if we really want to do it.

grochocki commented 5 years ago

Let's fix the issue for standard mode, but leave converters for now. I have not seen any feedback about scientific notation support in converters, so we can revisit later, if necessary.