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

Using Doubles vs Decimals in XlsIO

I write accounting software and I never use doubles because of the precision and everyone says not to for money. I'm wondering if this is going to get me in trouble because the your Number is a double.

When I'm reading in to an object I create I use:
myDecimal = Convert.ToDecimal( sheet.Range[rowcount, 12].Number);

When I'm creating a sheet I use
worksheet.Range[rowcount, 2].Number = Convert.ToDouble(myDecimal);
worksheet.Range[rowcount, 2].NumberFormat = "$#,##0.00";

Should I be using number here? Since I'm only setting values, will I not get into trouble? If excel does calculations with the doubles will there be a problem?




1 Reply

MM Manikandan M Syncfusion Team August 23, 2011 01:58 PM UTC

Hi Dan Parker,

Thank you for your interest in Syncfusion product.

Using Number format is correct. It would not create any problem if double value is stored in number format as you did. And Calculation can be done without any problem.

Thanks,
Manikandan.M




Loader.
Live Chat Icon For mobile
Up arrow icon