次のように、float および double から C# 5.0 仕様 (段落 6.2.1) で説明されている任意の整数型への明示的な数値変換。
• float または double から整数型への変換の場合、処理は、変換が行われるオーバーフロー チェック コンテキスト (§7.6.12) によって異なります。
o In a checked context, the conversion proceeds as follows: • If the value of the operand is NaN or infinite, a System.OverflowException is thrown. • Otherwise, the source operand is rounded towards zero to the nearest integral value. If this integral value is within the range of the destination type then this value is the result of the conversion. • Otherwise, a System.OverflowException is thrown. o In an unchecked context, the conversion always succeeds, and proceeds as follows. • If the value of the operand is NaN or infinite, the result of the conversion is an unspecified value of the destination type. • Otherwise, the source operand is rounded towards zero to the nearest integral value. If this integral value is within the range of the destination type then this value is the result of the conversion. • Otherwise, the result of the conversion is an unspecified value of the destination type.
同時に、次のようにMSDNで説明されている同じ変換のルール:
double または float 値から整数型に変換すると、値が切り捨てられます。結果の整数値が宛先値の範囲外である場合、結果はオーバーフロー チェック コンテキストに依存します。チェックされたコンテキストでは、OverflowException がスローされますが、チェックされていないコンテキストでは、結果は宛先タイプの未指定の値になります。
このような変換を評価すると、たとえば "(int)123.566" は "123" になります。仕様書の記載は正しいですか?