Jon Jagger
Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specificationpreviousnextprevious at this levelnext at this level 11 Typesprevious at this levelnext at this level 11.1 Value typesprevious at this levelnext at this level 11.1.6 The decimal type Paragraph 11 The decimal type is a 128-bit data type suitable for financial and monetary calculations. 2 The decimal type can represent values ranging from 1.0 × 10-28 to approximately 7.9 × 1028 with 28-29 significant digits. Paragraph 21 The finite set of values of type decimal are of the form -1s × c × 10-e, where the sign s is 0 or 1, the coefficient c is given by 0 ≤ c < 296, and the scale e is such that 0 ≤ e ≤ 28. 2 The decimal type does not support signed zeros, infinities, or NaN's. Paragraph 31 A decimal is represented as a 96-bit integer scaled by a power of ten. 2 For decimals with an absolute value less than 1.0m, the value is exact to the 28th decimal place, but no further. 3 For decimals with an absolute value greater than or equal to 1.0m, the value is exact to 28 or 29 digits. 4 Contrary to the float and double data types, decimal fractional numbers such as 0.1 can be represented exactly in the decimal representation. 5 In the float and double representations, such numbers are often infinite fractions, making those representations more prone to round-off errors. Paragraph 41 If one of the operands of a binary operator is of type decimal, then the other operand must be of an integral type or of type decimal. 2 If an integral type operand is present, it is converted to decimal before the operation is performed. Paragraph 51 The result of an operation on values of type decimal is that which would result from calculating an exact result (preserving scale, as defined for each operator) and then rounding to fit the representation. 2 Results are rounded to the nearest representable value, and, when a result is equally close to two representable values, to the value that has an even number in the least significant digit position (this is known as "banker's rounding"). 3 That is, results are exact to 28 or 29 digits, but to no more than 28 decimal places. 4 A zero result always has a sign of 0 and a scale of 0. Paragraph 61 If a decimal arithmetic operation produces a value that is too small for the decimal format after rounding, the result of the operation becomes zero. 2 If a decimal arithmetic operation produces a result that is too large for the decimal format, a System.OverflowException is thrown. Paragraph 71 The decimal type has greater precision but smaller range than the floating-point types. 2 Thus, conversions from the floating-point types to decimal might produce overflow exceptions, and conversions from decimal to the floating-point types might cause loss of precision. 3 For these reasons, no implicit conversions exist between the floating-point types and decimal, and without explicit casts, it is not possible to mix floating-point and decimal operands in the same expression.
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS