```
/** Render a value as fixed-width unsigned binary, nibble-grouped. */
export function formatBits(value: number, width: number): string {
  if (!Number.isInteger(value) || value < 0) {
    throw new Error("value must be a non-negative integer");
  }
  if (width <= 0 || width % 4 !== 0 || width > 32) {
    throw new Error(`width must be a positive multiple of four and not exceed 32`);
  }

  const binaryString = value.toString(2).padStart(width, '0');
  const nibbles = binaryString.match(/.{1,4}/g)!;
  return nibbles.join(' ');
}
```