Skip to main content

Coercion and the Type Cast

This video presents the same text shown beside it, spoken and on screen. It adds nothing the text does not say.

State

Coercion is relaxed type checking — a smaller type's value fits legally into a larger one — while the reverse requires a type cast, forcing a larger value into a smaller space.

Show

A two-byte count assigned into four bytes passes untouched; the reverse trip needs paperwork.

Watch for

The paperwork exists because the reverse trip has consequences.