Idea

The low-order bits of a sum, a product or a bitwise operation depend only on those of the operands

Info

Originally written in French. Translated by AI — the meaning has been preserved, not the prose.

Main idea

For addition, subtraction, multiplication and the and, or, xor operations, the $k$ low-order bits of the result depend only on the $k$ low-order bits of the operands. Computing a color formula in 16 bits (type Word in Turbo Pascal) or in 32 bits therefore gives the same final byte: word width does not matter as long as you keep only the bottom of the result.

The property breaks down for integer division and modulo, which "see" the high-order bits. In a formula that uses them, overflow of the original word width is part of the result.

Why it matters

This property says exactly when you can change the computation width without changing the image — and therefore, conversely, in which formulas a port must reproduce the word width of the original machine.

Nuances and limits

It assumes two's-complement arithmetic. Right shifts and comparisons are also sensitive to the high-order bits.

Open questions

  • Can the operations that make a formula's result depend on word width be detected automatically?