- 2 From sbyte to byte, ushort, uint, ulong, or char.
- 3 From byte to sbyte and char.
- 4 From short to sbyte, byte, ushort, uint, ulong, or char.
- 5 From ushort to sbyte, byte, short, or char.
- 6 From int to sbyte, byte, short, ushort, uint, ulong, or char.
- 7 From uint to sbyte, byte, short, ushort, int, or char.
- 8 From long to sbyte, byte, short, ushort, int, uint, ulong, or char.
- 9 From ulong to sbyte, byte, short, ushort, int, uint, long, or char.
- 10 From char to sbyte, byte, or short.
- 11 From float to sbyte, byte, short, ushort, int, uint, long, ulong, char, or decimal.
- 12 From double to sbyte, byte, short, ushort, int, uint, long, ulong, char, float, or decimal.
- 13 From decimal to sbyte, byte, short, ushort, int, uint, long, ulong, char, float, or double.

- 3 For a conversion from an integral type to another integral type, the processing depends on the overflow checking context (§14.5.12) in which the conversion takes place:
- 4 In a checked context, the conversion succeeds if the value of the source operand is within the range of the destination type, but throws a System.OverflowException if the value of the source operand is outside the range of the destination type.
- 5 In an unchecked context, the conversion always succeeds, and proceeds as follows:
- 6 If the source type is larger than the destination type, then the source value is truncated by discarding its "extra" most significant bits. 7 The result is then treated as a value of the destination type.
- 8 If the source type is smaller than the destination type, then the source value is either sign-extended or zero-extended so that it is the same size as the destination type. 9 Sign-extension is used if the source type is signed; zero-extension is used if the source type is unsigned. 10 The result is then treated as a value of the destination type.
- 11 If the source type is the same size as the destination type, then the source value is treated as a value of the destination type.
- 12 For a conversion from decimal to an integral type, the source value is rounded towards zero to the nearest integral value, and this integral value becomes the result of the conversion. 13 If the resulting integral value is outside the range of the destination type, a System.OverflowException is thrown.
- 14 For a conversion from float or double to an integral type, the processing depends on the overflow-checking context (§14.5.12) in which the conversion takes place:
- 15 In a checked context, the conversion proceeds as follows:
- 16 The value is rounded towards zero to the nearest integral value. 17 If this integral value is within the range of the destination type, then this value is the result of the conversion.
- 18 Otherwise, a System.OverflowException is thrown.
- 19 In an unchecked context, the conversion always succeeds, and proceeds as follows:
- 23 For a conversion from double to float, the double value is rounded to the nearest float value. 24 If the double value is too small to represent as a float, the result becomes positive zero or negative zero. 25 If the double value is too large to represent as a float, the result becomes positive infinity or negative infinity. 26 If the double value is NaN, the result is also NaN.
- 27 For a conversion from float or double to decimal, the source value is converted to decimal representation and rounded to the nearest number after the 28th decimal place if required (§11.1.6). 28 If the source value is too small to represent as a decimal, the result becomes zero. 29 If the source value is NaN, infinity, or too large to represent as a decimal, a System.OverflowException is thrown.
- 30 For a conversion from decimal to float or double, the decimal value is rounded to the nearest double or float value. 31 While this conversion may lose precision, it never causes an exception to be thrown.

| |

Jagger Software Ltd | |

Company # 4070126 | |

VAT # 762 5213 42 |