Which C# data type will result in the least amount of rounding?
We deal with lot's of numbers and they are generally pretty big (100's of millions + 4 decimal places).
What is the best strategy regarding data types? I need to maintan consistancy without losing decimal places or rounding.
-
-
If you always use a consistent number of decimal places, Decimal is the way to go.
If you want "as high precision as possible", and performance is a plus, Double is the way to go.
If your accuracy needs are not particularly great, Float is the way to go. -
You will need either a decimal or double.
A float can only hold 7 digits (not enough for this).
A double can hold 15-16 digits and a decimal can hold 28-29 significant digits.
See http://msdn2.microsoft.com/en-us/s1ax56ch(VS.80).aspx">http://msdn2.microsoft.com/en-us/s1ax56ch(VS.80).aspx for more info on value types.
____________Compilr - the online compilr C#, C, VB.NET, Fortran
http://thehackman.blogspot.com/">http://thehackman.blogspot.com
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.