jr.9
❔ Can you convert from an excel sheet double to decimal for currency math?
I'm importing an excel spreadsheet (xlsx) into my C# project using ExcelDataReader.DataSet and it just imports everything from the spreadsheet as it's saved. So numbers are imported as doubles. The sheet I'm working with has dollar values ranging from $0.25 to $10 or so - no real big numbers, maybe $99 at the absolute most once in a blue moon.
My question is - is it safe to convert the double to a decimal to do currency math with? It obviously can't add or remove extra numbers to the end ($1.250000006 for instance) since that may screw up the calculations and they can't be off by even one cent.
35 replies