Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Always use InvariantCulture when converting from/to floats#16

Open
benediktwerner wants to merge 1 commit intosinai-dev:mainfrom
benediktwerner:main
Open

Always use InvariantCulture when converting from/to floats#16
benediktwerner wants to merge 1 commit intosinai-dev:mainfrom
benediktwerner:main

Conversation

@benediktwerner
Copy link

Fixes #15

I'm actually rather confused why the current code doesn't already work and just allows me to use , everywhere. After looking into it a bit, apparently, during the first call to InteractiveNumber.RefreshUIForValue, CurrentCulture is set to de-DE i.e. German as expected but on later calls to both it and InteractiveNumber.SetValueFromInput, it's unset. CurrentUICulture is always set to German though but it doesn't seem to impact whether a period or comma is used for parsing and printing.

So during the initial refresh, the input is set to 3,5 but then on all further calls it wants 3.5.

Not really sure why this is, I guess apparently the culture is set per thread and maybe the other calls run in another thread where the culture isn't set or is reset for some reason?

I guess if you know why this happens, maybe you can find a better fix. Otherwise, the proposed changes work as expected though I guess it's a bit annoying to have to specify the culture everywhere and I guess is also a bit brittle since it's easy to forget but not sure there's a much better solution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken float handling

1 participant