The Decimal Type

In the category of real types, you’ve learned about floating-point types so far. Despite their wide range, the imprecision that comes with them may sometimes be problematic, especially in the context of financial calculations. To provide an answer to this, the BCL offers a System.Decimal type that is surfaced in C# through the decimal keyword.

decimal is a 128-bit value with a smaller range than the floating-point numbers but with higher precision due to exact decimal representations. These two properties apply very well in the world of financial computing: Scales over a decimal order of magnitude of 300 (as with double) are ridiculously high, and the ability to represent simple values like 0.30 (for example, to denote 30 cents) ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.