トランケーション・エラーは、あるプリミティブをより小さなサイズのプリミティブにキャストする際に、変換中にデータが失われた場合に発生する。
プリミティブをより小さいプリミティブにキャストすると、大きな値の高次ビットが変換で失われ、元の値と等しくない予期しない値が生じる可能性があります。この値は、バッファへのインデックス、ループのイテレータ、または単に必要な状態データとして要求される可能性があります。いずれにせよ、この値は信頼できず、システムは未定義の状態になります。この方法は、値の下位ビットを分離するのに有効かもしれないが、このような使い方はまれであり、切り捨ては通常、実装エラーが発生したことを意味する。
Truncation errors occur when a primitive is cast to a primitive of a smaller size and data is lost in the conversion.
When a primitive is cast to a smaller primitive, the high order bits of the large value are lost in the conversion, potentially resulting in an unexpected value that is not equal to the original value. This value may be required as an index into a buffer, a loop iterator, or simply necessary state data. In any case, the value cannot be trusted and the system will be in an undefined state. While this method may be employed viably to isolate the low bits of a value, this usage is rare, and truncation usually implies that an implementation error has occurred.