Information Technology Reference
In-Depth Information
float or double to Integral
When converting a floating point type to an integer type, the value is rounded toward zero to
the nearest integer. Figure 18-12 illustrates the conversion conditions. If the rounded value is
not within the range of the target type, then
￿The CLR raises an OverflowException exception if the overflow checking context is
checked .
C# does not define what its value should be if the context is unchecked .
￿
Figure 18-12. Converting a float or a double to an integral type
decimal to Integral
When converting from decimal to the integer types, the CLR raises an OverflowException
exception if the resulting value is not within the target type's range. Figure 18-13 illustrates the
conversion conditions.
Figure 18-13. Converting a decimal to an integral
Search WWH ::




Custom Search