Monday, September 10, 2018

So why only 107 symbols in Code 128?

Sometimes you just wonder why things have a certain number of possibilities. Like code 128 barcodes. Why does it have a certain # of symbols?

From https://en.wikipedia.org/wiki/Code_128

It's got a constant 11 bit width with 3 bars and 3 spaces. Each bar can be from 1 to 4 units thick.

So you have 6 bars and they can have 4 possibilities each.

You'd think it would be 4 * 4 * 4 * 4 * 4 = 4096 possibilities, but the number of units all has to add up to 11.

Let's write some javascript to do some counting for us:




and it dutifully gives us 216 possibilities.

If we remove half of those 216 taking away the reverse bit patterns, we get 108 which is pretty close to the 107 symbols that you can have in code 128.

No comments:

Post a Comment