Minecraft – How to halve redstone signal strength

minecraft-java-editionminecraft-redstone

I'd like the output signal to be half the input signal strength.

I was able to use the 'lookup table' approach, which can convert pretty much any input to any output, but is bulky, noisy, somewhat slow, and quite expensive.
enter image description here

Is there a neater, more compact, or faster way to convert input signal strength 0-15 into range 0-8 (or similar, small off-by-one changes allowed, e.g. 0,1->0; 14,15->7).

Bonus: divide by a different number?

Best Answer

What about this? When you make your input two units stronger, your output increases by one.

Edit:

This is rather slow, because it takes up to 8 ticks (one for the last repeater plus one for each of the following comparators) to update the output.

Inspired by Fabian Rölling's faster (only one tick) solution, I found out that lining up the repeater's output to adjacent blocks leads to an even more compact solution for the division by two:

side image division by 2top image division by 2

Note that the redstone signal can climb up slabs but not down!

Each repeater is reached in two steps more compared to the previous repeater. The last repeater reached is crucial for the result. Because the output blocks of the repeaters are adjacent, the signal's power is reduced by one for each unused repeater passed.

From this pattern, we can derive solutions for a division by any number, for example by three:

side image division by 3top image division by 3

Please note that the input to the repeater can come from behind the adjacent solid block. Here each repeater is reached in three steps more compared to the previous one.

The division by five turns out to be very simple: division by 5