Friday, 3 April 2009

Decimal versus Double

I was trying to remember the difference between a decimal and a double and came upon this handy little reference on MSDN


Essentially decimals have a far greater level of precision but doubles have a much larger range. However in most case when dealing with UI why would you ever need the range of a double?

My ten cents anyway

Mind you, when you save it to the database it shrinks it down to whatever your DBA thought was appropriate anyway :)

1 comment:

  1. One important thing to know is to use Decimal when dealing with money, to prevent rounding errors. If using floating point numbers seriously, you need to understand their nuances. Some good references:
    1. http://www.extremeoptimization.com/resources/Articles/FPDotNetConceptsAndFormats.aspx
    2. http://www.yoda.arachsys.com/csharp/floatingpoint.html

    ReplyDelete