Double Edit Box accepts NaN only in english culture

Editors for WPF Forum

Posted 5 years ago by Sascha Kröger - GLM Lasermesstechnik GmbH
Version: 14.1.0602
Platform: .NET 4.5
Environment: Windows 8 (64-bit)

Dear Support Team,

I found an issue regarding the DoubleEditBox Editor.

In our software the user should be able to enter NaN values and Infinity values into a variable of type double. I think the DoubleEditBox Editor should be the right selection and it works pretty good if our program is running with english UI culture. But if the Software uses the german UI culture, which is a default setting in Germany, the user can't use NaN or Infinity for Input.

In the german UI culture of the .net framework the "NaN" symbol is defined as "n.def." which means "nicht definiert" (not defined).
If the user press the "n" key (in german UI context) the content ("n.def.") is shown, but this value is not accepted by the Edit Box.

Pressing "i" (Infinity) doesn't work, too. This is obvious because Infinity is called "unendlich" in german.

So I thought pressing the "u" should work. But this fails, too.
You can press "-" and then "u" to get "-unendlich" (negative Infinity). This value will be accepted by the Edit Box.
To input positiv Infinity you have to press "+". Immediatly "+unendlich" is shown. This value is acccepted, too.

But I have not found a way how the NaN Value (n.def) will be accepted. How can I solve this issue?

Kind regards,

Christof Konstantinoppoulos

[Modified 5 years ago]

Comments (4)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Christof,

When you set AllowNaN or AllowInfinity on the DoubleEditBox, it updates the core regular expression mask to allow the text options specified by:

  • CultureInfo.CurrentCulture.NumberFormat.NaNSymbol

  • CultureInfo.CurrentCulture.NumberFormat.PositiveInfinitySymbol

  • CultureInfo.CurrentCulture.NumberFormat.NegativeInfinitySymbol

In US English culture, those end up being "NaN", "Infinity", and "-Infinity".

When converting back from the entered text to get a double, we do:

double.TryParse(stringValue, NumberStyles.Any, CultureInfo.CurrentCulture, out value)

I just tried switching my system to display numbers in de-DE culture and it shows the values above as "NaN", "+unendlich", and "-unendlich".  Do you see something different when you examine those system properties?

Actipro Software Support

Posted 5 years ago by Sascha Kröger - GLM Lasermesstechnik GmbH

Thank you for your answer.

It seems that the .net Framework behaves different on a german system. I get "n. def." instead of "NaN" on my system. "+unendlich" and "-unendlich" are the same.

I have tried following code and it works on my system:

var strInput = double.NaN.ToString();
Debug.WriteLine(strInput);  // output = n. def.

double result;
var OK = double.TryParse(strInput, NumberStyles.Any, CultureInfo.CurrentCulture, out result);
Debug.Assert(double.IsNaN(result)); // OK = true, Assertion also OK, This means "result" is equal to NaN

So your code line seems to be OK.

But now I see the problem. You updates the core regular expression with the text given by NumberFormat.NaNSymbol. But "n. def." contains a dot. And the dot "." is an invalid symbol because in german culture a colon "," is used instead. [3.14 (english) and 3,14 (german)].

So the Text "n.def." can't be accepted by the regular expression.

It seems, that you check the string value for invalid characters before you call the double.TryParse method. Is it possible to change the checking order?

Kind regards,

Christof Konstantinopoulos

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Christof,

I believe that the problem isn't necessary that but rather that we need to do a regex escape of the alternation options we add for localized NaN and infinity text.  I tried a test here and think it will work but it would be nice to have you validate it as well since your system generates this scenario and ours doesn't.  If you would like to try a preview build, please write our support address and reference this thread.  Thanks!

Actipro Software Support

Answer - Posted 5 years ago by Sascha Kröger - GLM Lasermesstechnik GmbH

Dear support team,

of course I can validate your changes on our german system. I already have send an e-mail to your support address.

Based on the new information I realized, that I have used a wrong subject line for this thread. I think the correct subject line would be
"Double Edit Box doesn't accept localized NaN on german operating system."

Even if the subject line can not be changed, I want to clarify this for other users.

Kind regards,

Christof Konstantinopoulos

[Edit 2014-06-11 by CK]
I have tested the preBuild version today and the NaN issue is solved. Many thanks to the Developer Team.

[Modified 5 years ago]

The latest build of this product (v2019.1 build 0681) was released 18 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.