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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problem with decimal separator - What am I missing?

Thread ID:





72345 Mar 14,2008 01:43 PM UTC Mar 17,2008 09:08 AM UTC WinForms 2
Tags: Calculate
Lars Lundstedt
Asked On March 14, 2008 01:43 PM UTC

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?

Replied On 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

Lars Lundstedt
Replied On March 17, 2008 09:08 AM UTC

Worked like a charm...thank you!


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon