Table of contents >> Introduction > Decimal variable type
High importance article

decimal variable type, unlike float and double, which are binary point types, is a floating decimal point type. It can store 128 bits, and compared to the float or double types, it has more precision and a smaller range. This makes it best suitable for financial calculations and any situations where precision is crucial. The decimal variable type can store values between 7.9E-28 and 7.9E+28

If you want a numeric real literal to be treated as decimal, use the suffix m or M, for example:

1
decimal myDecimalVariable = 157.39M;

Without the suffix m, the number is treated as a double and generates a compiler error.

The concepts explained in this lesson are also shown visually as part of the following video: