microsoft / calculator

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

Support both `.` and `,` as decimal separator when entering numbers #153

Open ThiefMaster opened 5 years ago

ThiefMaster commented 5 years ago

Problem Statement The Windows 7 calculator allowed users to enter both . and , as the decimal separator. This is very convenient because while certain locales uses , (e.g. German) as the decimal separator, it's still very common on websites, applications, etc. to use the . separator. Supporting both allows for flexibility when entering values.

Evidence or User Insights The calculator in Windows 7 supported this.

Proposal The calculator should accept both . and , as a decimal separator.

Goals User can enter both . and , as a decimal separator


The only tricky point I see here is how pasting numbers should be handled:

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.

aaaxx commented 5 years ago

For ambiguous cases, marking them and offering the user some kind of UI to point out the right character or place a new one would be much more user friendly than rejecting the input.

Also, all Unicode spaces should probably be treated as digit grouping character (i.e., silently dropped), whether pasting or typing the number.

KillyMXI commented 5 years ago

In the discussion of PR #145 some ambiguities were shown. I have written a similar format interpretation logic there before I found this ticket. I wonder if it's a good idea to copy it here.

Update: that PR was just locked to comply with contribution process. I'm waiting to see which issue will be used for discussion.

grochocki commented 5 years ago

@ThiefMaster Thanks for submitting your idea! We agree there is likely something we can do to improve this experience, but it would be good to refine the idea a bit more before moving forward.

The Windows 7 calculator allowed users to enter both . and , as the decimal separator... Supporting both allows for flexibility when entering values.

We agree that regardless to your PC's language settings, we should be able to handle pasted input with both separators. Is this what you had in mind? Or would you expect the ability for a user to type input with physical or in-app keyboard to do the same? In general, we want to respect the system settings for direct input. If you prefer one style over the other, you can change this in your language settings.

If exactly one separator is present, it's ambiguous what it should mean. The Win7 behavior here is to only allow the separator of the current locale when pasting, and treating the other one as a thousands separator that should be ignored.

I agree this can be tricky, and maybe we can figure out the details later, but can you clarify what you mean in this case? For example, what would you expect if I pasted "123.456"

For ambiguous cases, marking them and offering the user some kind of UI to point out the right character or place a new one would be much more user friendly than rejecting the input.

We worry that this might easily become too complex, and in general, we want to avoid blocking UI like popups. Ideally, we can handle all scenarios more fluidly without requiring additional user action.

@KillyMXI We should use this issue to track improvements to this, so let's keep the conversation here until we figure out how to tackle this.

ThiefMaster commented 5 years ago

Or would you expect the ability for a user to type input with physical or in-app keyboard to do the same?

Yes, that's indeed what I had in mind. Like I said, on Windows 7's calc this worked just fine. I think most apps just use the system setting for output (well to be honest, many completely ignore them) but follow the principle of "be lenient in what you accept for input, but be strict of what you output".

I-Campbell commented 5 years ago

General conference on weights and measures say: Decimal place can be either '.' or ',' Thousands and Thousandths separator can be a thin space. '.' nor ',' should not be used as thousands nor thousandths separators to avoid confusion.

So I think it is reasonable that:

  1. If only one occurance of only one separator then this is treated as a decimal place.
  2. If two occurances of one separator exist and only 1 or none of the other separator, treat the repeated separator as a thousandths or thousands separator.
  3. If one each of two different separators are present, use the local language settings to figure out which is the decimal separator.
  4. If two occurunces of both separators exist ( ie. an erroneous entry) remove all separators and let the user correct.

Examples: 10,000: ten 10.000: ten 10,000.00: ten thousand in Australia, ten in Germany. 10.000,00: ten in Australia, ten thousand in Germany. 10,000.000,00: ten thousand 10.000,000.00: ten thousand 10.000.000,000,000: ten trillion (ignore all separators)

I think this should be the same for pasted input or typed input.

Any calc documentation on numerical entry should point out the importance of numerical unambiguity across cultures, and they should be using , or . for decimal place and either a thin space or nothing at all as both a thousandth or thousands separator.

ThiefMaster commented 5 years ago

Since I just got reminded of this issue thanks to the (very interesting!) comment, another idea regarding this came to my mind:

Or would you expect the ability for a user to type input with physical or in-app keyboard to do the same?

If you type a number, chances are good that you will never enter thousands separators. So I think for that case it makes sense to accept both . and , as the decimal separator (and reject any repeated input of either of those chars once one has been used).

HowardWolosky commented 5 years ago

If you type a number, chances are good that you will never enter thousands separators.

Unless you're copying and pasting a number from somewhere else that was formatted that way....

ThiefMaster commented 5 years ago

Sure, but it's easy to detect whether it's copy&paste or actual typing.

I-Campbell commented 5 years ago

@ThiefMaster: I agree. That also complies with Weights and Measures, so I like your one better for typing. You can expect the user to copy/paste text written by non-compliant authors though, in which case my disambiguation cases should be used.

@HowardWolosky: copy paste and typing are different code areas.

miloush commented 5 years ago

@I-Campbell what is the standard you are suggesting compliance to, and how is it better for end users than CLDR?

I-Campbell commented 5 years ago

@miloush:

https://www.bipm.org/en/CGPM/db/22/10/

These guys do the SI units.

CLDR is for what the user is likely to enter, but fails to recognise that the user is a global citizen and may be copy pasting from a website from another country.

miloush commented 5 years ago

@I-Campbell Thanks.

Some of the behavior you propose is breaking (i.e. changes what the calculator, both Win32 and UWP, currently does for the same input). I would argue global citizen should have their preferences respected, and I would be cautious about re-interpreting pasted values, especially in unit conversion where it can create confusion. Don't also forget that currently there is no way for user to edit entered numbers.

This issue seems to propose both the dot and comma keys to be treated as a decimal separator, the same way Win32 calculator does it, which would on its own be a significant improvement. The discussion seems to have been focusing on resolving ambiguities, but the calculator already supports pasting values, for both "10,000" and "10.000", so perhaps if users are unsatisfied with how that currently works, a new issue should be opened.

Don't forget that user can set the decimal and grouping separator to be the same character, and/or more than one character (the UWP uses the first character only though, unlike Win32).

thomaslevesque commented 5 years ago

A compromise could be to make the new behavior optional. Personally, I never use the thousands separator when typing a number, and it's rarely present in numbers I try to copy/paste, so I'd like to interpret '.' as the decimal separator, even though in my locale (French) the standard separator is ','.

jgleal commented 5 years ago

I think nobody uses thousands separator when write a number... Isn't more logicall respect the decimal separator of language configuration and ignore thousands separator?

thomaslevesque commented 5 years ago

Isn't more logicall respect the decimal separator of language configuration

More logical, maybe, but not necessarily more convenient. The decimal separator in my language is ',', but as a programmer I'm used to use '.'. So I'd like to be able to use either.

ghost commented 5 years ago

This pitch looks like it has everything it needs for review. In the meantime, we'll keep this idea open for discussion so the community has the chance to provide feedback. Check out our New Feedback Process for more info on the user-centered process we follow for new feature development.

0x49D1 commented 5 years ago

I just can't copy numbers from calculator anymore: 10,023,100 is NOT treated as 10023100! Why on earth should I copy the FORMATTED numbers? The main problem is with the websites who check if the pasted value is ASCII characters and they just fail after I paste "," and "save the memory about my pasted values" until I hide the input field (Hello AWS S3 headers parameter section!). Can we just COPY the number from calculator WITHOUT grouping commas? I really don't even want such "grouping", but there is no option to disable that feature.

grochocki commented 5 years ago

Thank you to everyone for the great discussion on this issue. We had the chance to review the idea more closely, and we feel like we need more information before deciding whether to continue.

First, the support we have today for accepting pasted values when they are formatted to align with your system settings has one key benefit--it is consistent and predictable with how numbers are represented throughout the rest of the system.

That being said, we definitely understand the user pain point this change is seeking to address. We are generally supportive of this pitch, as long as we can consistently and predictably handle pasted input regardless to what your region's thousands and decimal separators may be (comma, period, space, etc.)

The ambiguous cases are the problem. Is "100,000" "one hundred" or "one hundred thousand"? Thanks to folks who have proposed rules above, but we don't think we've landed on a good set of rules here. Unlike #162, where there is only a possible loss of precision, making the wrong assumption here can result in huge swings in order of magnitude. We cannot think of a good way to confidently determine one way or another, so we would like to keep this idea and discussion alive and take another look once we have clearer set of rules we can follow.

I-Campbell commented 5 years ago

I think, at least for the first ambiguous paste you will have to interrupt the user. "Hi, we don't like to make assumptions! It is possible you have pasted values from one of these sources:

0x49D1 commented 5 years ago

The ambiguous cases are the problem. Is "100,000" "one hundred" or "one hundred thousand"? Thanks to folks who have proposed rules above, but we don't think we've landed on a good set of rules here. Unlike #162, where there is only a possible loss of precision, making the wrong assumption here can result in huge swings in order of magnitude. We cannot think of a good way to confidently determine one way or another, so we would like to keep this idea and discussion alive and take another look once we have clearer set of rules we can follow.

Let me explain more. The real problem in my case was is not even 100,000 or 100.00 or 100000: many web services accept only integers (almost all, even in HTML standard number field there is clear INT), and not when I do select all and then copy & paste into the number input - it pastes with 100,000 so that the field validation fails. I always have to remove the ','. How is this connected to the way I set the localization/culture settings on my PC? That settings are just representation, the default must be determined by the service where I paste the number in some standard notation (as I know the standard pure number with '.' as decimal separator). Sure I'm not an expert in the question, but the updated calculator made paste experience for me just painful. The old version without additional cultural formatting was way better (probably not just for me).

ThiefMaster commented 5 years ago

Yeah I think copying should strip anything except the decimal point, and pasting should try to be smart - if there's only one way to parse use that, otherwise prompt the user.

And when typing... well, nobody types thousands separators, so both .. and , should be a decimal point then (and typing more than one should of course be disallowed).

KillyMXI commented 5 years ago

@0x49D1 you talk about different issue from what is discussed here, I believe. For issues with copying FROM Calculator you better open a separate issue. That will be more effective.

KillyMXI commented 5 years ago

I can see the appeal of a configuration-free and dialog-free application in the smartphone era. But it also puts irresolvable constrains, making the app the least useful for the real world. Some level of flexibility is important to be able to integrate into workflows involving different systems developed with different mindsets... As a developer, mainly working with data in culture-invariant format, but having different regional format, the current Calculator logic totally fails the reality check and rendered useless most of the times for me.

I was going to refine my parser logic suggestion before posting it here. But it looks like more fundamental roadblock have to be moved first.

My suggestion is to add alternative paste command and alternative parser. Also refine existing parsers for all modes while at it.

All parsers:

Fall-through rules (inspired by comments in #162):

This way, the main track will remain consistent and dialog-free. But there will be a flexible alternative to deal with real world scenarios.

I also have to note that "consistent" is not "error-free". I still have to pay attention, or Calculator will ignore the decimal separator when I paste 1.2 for example. That's why I would rather have a side track that I consciously choose to have all ambiguities captured and confirmed.

thomaslevesque commented 5 years ago

I like @KillyMXI's suggestion.

Another way of handling this would be to show a hint on paste, like in Word:

image

For instance, if the user pastes "100.000", parse it as 100.0, but show a hint saying "Did you mean 100 000" or something similar. Of course there would be a bit of UX work to make it nice and easy to use.

I-Campbell commented 5 years ago

@Thomaslevesque I love the paste options dialogue idea. Everyone is familiar with that functionality. It also doubles as a known keyboard shortcut, as everyone knows from word that you can press Ctrl+V, Ctrl, and then a key for each of the options. M for Mine, E for Europe, A for America, S for Standards? Can I request Standards is default paste, or is that too rude?

leduyquang753 commented 4 years ago

I think there should be an option to opt for the dot to be the multiplication sign instead, as some countries like Vietnam use it like so.

image

miloush commented 4 years ago

@leduyquang753 this doesn't look like a source you can select text from and paste into the calculator, and even if you have a formatted text, it will be most likely pasted as 2.10-7 so you have other issues to solve first. Do you have an example where the dot is used for multiplication but not by powers of ten?

leduyquang753 commented 4 years ago

@leduyquang753 this doesn't look like a source you can select text from and paste into the calculator, and even if you have a formatted text, it will be most likely pasted as 2.10-7 so you have other issues to solve first. Do you have an example where the dot is used for multiplication but not by powers of ten?

It is right in the shot above: image

KillyMXI commented 4 years ago

@miloush @leduyquang753 this better be discussed in the linked issue. https://github.com/microsoft/calculator/issues/1251

For the current issue, it's sufficient to mention that in some cultures full stop can even be not a separator but a mathematical operation.

Leopold702 commented 2 years ago

Because of this issue, it's also not possible to copy results from converter to the calculator, which is very annoying. But it seems that this topic is dead, last update was almost two years ago.

Kaphaalor commented 2 years ago

While there is no definitive decision on how to handle copied numbers, the base principle of allowing for different user input is not influenced. I would therefore suggest to allow for both ',' and '.' as direct input via the keyboard, as this does not directly interact with pasting numbers.

rgrignon1 commented 2 years ago

This issue is 3 years old and still unsolved! There is a lot happening and could and should be split into multiple issues, with the first one being support for both . and , as decimal separator when typed. Everybody agreed that there is no ambiguity since people doesn't manually type thousands separators. Also, such change should be extremely simple to make it work.

Second issue: parsing. A lot of proposals have been made and I won't repeat what has already been said. I think we should always accept any valid format just as is when there is no ambiguity (ex: 1000.5 should always be parsed as 1000 + 5/10 because there is no alternate valid interpretation). In case of ambiguity, locale format should be used first (ex: 100,000 in french should be treated as 100 because , is by default the decimal separator). When unable to choose because multiple format works, but none is locale one, then we could decide further if it's better to choose one by default, force the default by removing ambiguous characters or throw an error.

Third issue that no one have pointed out so far: adding an option for changing the locale of the application, regardless of PCs one. I'm set up in french canadian, but as a programmer I always use . as a separator. Such config would probably solve the issue for 95% of people coming here, including me, and just like the first issue, the fix would be pretty simple with a selector on the side menu. For common users, this option could be ignored if they don't care.

bergamin commented 1 year ago

Either that or make it possible to change the decimal separator manually in the app's settings.

I was about to open a bug report because I changed my OS to English and it's still trying to use comma as a decimal separator like it is in the language the PC came with.

But then I found this and decided to support this one instead. I'm a programmer and I'm used to doing everything in English and that includes working with numbers. Using the dot is muscle memory and I get calculation mistakes all the time because of this.

I didn't have this problem in previous versions of Windows. It used to work with both dot and comma. Please fix this.

If anybody also have a Feedback Hub entry, please send a link for me to support there as well

andershedberg commented 11 months ago

I might as well chip in from Sweden. Whenever I type a number I automatically hit the . (dot) in the calculator for decimals, and it's just discarded and I end up with the wrong number... again and again every month. It's actually easier to use google/chrome for the math as it doesn't care. And I do know that we should use , (comma) but I just simply use too many US software programs every day...

ThiefMaster commented 8 months ago

5 years later, same problem... :/

bergamin commented 8 months ago

@grochocki, maybe we could deal with this issue as two separate issues. One to deal with typing, which has a clear unmistakable solution, which is to whenever you hit . or ,, that triggers the decimal separator and a second issue for pasting, which for now could stay the way it currently is until a definitive solution shows up (what i would do would be upon pasting, asking which character is the decimal separator)