I'm writing a financial application in C# where performance (i.e. speed) is critical. Because it's a financial app I have to use the Decimal datatype intensively.
I've optimized the code as much as I could with the help of a profiler. Before using Decimal, everything was done with the Double datatype and the speed was several times faster. However, Double is not an option because of its binary nature, causing a lot of precision errors over the course of multiple operations.
Is there any decimal library that I can interface with C# that could give me a performance improvement over the native Decimal datatype in .NET?
Based on the answers I already got, I noticed I was not clear enough, so here are some additional details:
Thanks!
you can use the long datatype. Sure, you won't be able to store fractions in there, but if you code your app to store pennies instead of pounds, you'll be ok. Accuracy is 100% for long datatypes, and unless you're working with vast numbers (use a 64-bit long type) you'll be ok.
If you can't mandate storing pennies, then wrap an integer in a class and use that.