We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Problem with decimal separator - What am I missing?

I'm evaluating Calculate on an English version of WinXP (SP2) with Swedish regional settings and I'm running into a strange problem with decimal separators when using CalcQuick.

The help file states that Calculate uses a period as the default separator. If I use a simple formula, e.g. 1.2 + 1.2, the period is ignored and the calculated result (using ParseAndCompute) is 24!

If I set CalcEngine.ParseDecimalSeparator to a comma and use the same formula, e.g. 1,2 + 1,2, I get the correct answer but that doesn't really help me since the application I'm thinking of using Calculate for will be distributed worldwide and regional settings just have to work.

I've tried changing the regional settings on my computer to English but that didn't help.

How can I get the class to accept a period as a decimal separator? What am I missing?



2 Replies

AN Anonymous March 14, 2008 03:10 PM UTC

Try these settings to see if they give you what you want.

cq = new CalcQuick();
CalcEngine.ParseDecimalSeparator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0];
CalcEngine.ParseArgumentSeparator = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator[0];

If the regional setting is Swedish and your users type 1,1+1,2 they should then get the value 2,3



LL Lars Lundstedt March 17, 2008 09:08 AM UTC

Worked like a charm...thank you!


Loader.
Live Chat Icon For mobile
Up arrow icon