PCM Arithmetic

If you wonder why 128 is the "perfect" value for BLMs and INTs, read on.  But beware, you'll have to wade out up to your knees in bits, bytes, and base 2 numbers.

Back to the PCM Tutorial


Why do INTs and BLMs of 128 mean that zero correction is needed to get the fuel mixture just right?  Why not use 0 for zero correction?  The PCM uses 1 byte of memory space to store each BLM and INT value.  In ordinary positive numbers (as opposed to binary or octal), 1 byte can represent any whole number (no fractions) from 0 to 255.  Halfway between 0 and 255 (more or less) is 128, so 128 is used to represent halfway between rich and lean, or "perfect".  If none of this makes sense, just remember that 128 is perfect for BLMs and INTs.  Trust me.

OK, the computer geeks have convinced me to add the next lesson.  A byte of data is the same as 8 bits of data, where a "bit" is a "binary digit", and each binary digit can only be a zero or a one.  (Please take a moment to brush up on your base-2 arithmetic.)  If you want your byte to represent both positive and negative numbers, you have to pick one of those bits to indicate the sign, either + or -.  Suppose you pick the bit on the left end of the 8 bits to be the sign bit.  Suppose that you want a sign bit of one to indicate that the number is positive, and a sign bit of zero to indicate that the number is negative.

In base 2, the decimal number 128 looks like this: 10000000.  The rightmost bit is the 2-to-the-0-power bit, the next one moving left is the 2-to-the-1st-power bit, the third one from the right is the 2-to-the-2nd-power bit, and so on.  Forgetting about sign bits for a moment, the leftmost bit would be the 2-to-the-7th-power bit, and 2 to the 7th power equals 128.  BUT, remember that we're letting the bit on the left represent the sign.  So the 7 bits that are left over represent the size, or magnitude, of the number.  If you look at 10000000 this way, it equals zero (positive zero to be picky, and 00000000 is negative zero, but they are equal).  It's the scan tools out there that report 10000000 as 128 instead of zero, so blame them for the confusion.

I'm NOT going to explain 2's complement in this tutorial, so you'll have to figure out for yourself why decimal 127, which is 01111111 in sign-less binary, is equal to -1 in our left-bit-is-the-sign-bit scenario.  I will tell you a trick, though, to find the magnitude of a 2's complement number.

Ignoring the leftmost bit, which just represents the sign of the number, you find the size of a negative 2's complement number by changing all the zeros to ones and all the ones to zeros (aka "inverting [or complementing] all the bits"), then adding one.  Of course this assumes you can do base 2 addition.  Anyway, if you invert the 7 magnitude bits in 01111111 and ignore the sign bit, you get 0000000.  Adding one gives 0000001, which is equal to decimal 1.  So 01111111 in 2's complement binary equals -1 in decimal.  And 01111111 in ordinary, sign-less binary is 127 in decimal.  As my old math teacher used to say, "Clear as mud, right?".

Anyway, if you accept that decimal 127, which is 0111111 in sign-less binary as I said above, works out to decimal -1 if you treat 01111111 as a 2's complement number, then the less-than-128-means-taking-out-fuel might make more sense.  Or maybe not.  To wrap this up, decimal 129, which looks like 10000001 in sign-less binary, is easily (I hope) seen to be positive 1 in our 2's complement scheme where the left-most one is just the sign bit.

In summary, if you switch from sign-less binary to 2's complement, the byte for 127 "changes" to -1 (take out fuel), the byte for 128 "changes" to zero (no adjustment), and the byte for 128 changes to +1 (add fuel).  Not surprisingly, 126 changes to -2, and 130 changes to +2.  And so it goes.