7

A search for Aiken code (2-4-2-1 binary coded decimal) yields many web pages and a video with a lecturer claiming (in virtually identical language- this is from Wikipedia) (emphasis added):

The code was developed by Howard Hathaway Aiken and is still used today in digital clocks, pocket calculators and similar devices.

I see no citations that would support the latter part of this claim. The 4-bit MCUs I am somewhat familiar with (eg. OKI, TI, even the Intel 4004 used in the first calculators) that would be used in single-cell watches and in pocket calculators, as far as I know use conventional 8-4-2-1 BCD in their nibble decimal adjust instructions (the add-6 algorithm).

In fact, in most of the places references to Aiken code appear it is in relation to artificial textbook problems and such like.

Is there a known practical application of this code in "digital clocks, pocket calculators and similar devices" the last 20 or 30 years?

hacktastical
  • 49,832
  • 2
  • 47
  • 138
Spehro Pefhany
  • 376,485
  • 21
  • 320
  • 842
  • 1
    Reading about Aiken coding, I'd say something like: "Every day bears the promise of learning something new!", but honestly: um, why would anyone? I mean, sure, BCD is already a bit obscure and doesn't make sense for things where the decimal system is only relevant for human interaction, since humans are ridiculously slow at reading or typing numbers, and if, only for strange (banking/accounting?) applications where "actual math" rules aren't "correct" and you need to do intermediate rounding in a decimal system, even if you *would* have enough bitwidth to avoid rounding at all… – Marcus Müller Jan 27 '23 at 22:11
  • 1
    8-4-2-1 BCD is unquestionably used in most calculators, clocks, digital thermometers and such like, partly because it takes a lot of cycles to convert binary to and from displayable characters compared to the amount of math that has to take place (even the math that is used to linearize thermistors). And there is also the rounding issue important on calculators. For clocks, counting mod-60 etc. you might as well use BCD. RTCC chips I think mostly use packed BCD. – Spehro Pefhany Jan 27 '23 at 22:21
  • 1
    …but Aiken takes the cake! You can trivially add digits, unless the result falls into the middle "pseudotetrate", which you need to detect with an actual 4-bit comparison (so, like… like a 4-bit look-up table that would be sufficient add digits in *any* 4-bit system), subtracting is "easy", because it's addition with the bit-inverse, but of course you need to check for pseudotetrates both ways… It's as far from Gray-coded as you get without trying, to top it all off. *What's the good thing about it?* – Marcus Müller Jan 27 '23 at 22:21
  • Re: math it takes to display vs to calculate: sure, if your calculator only has +-\*/ that might be true (I'd already have questions about the division, because that stuff is hard enough in binary for binary computers, and human long division kind of badly translates into cycles), but it's been a while since I saw a calculator without a \$\sqrt.\$, and that *really* gets messier in decimal than the conversion (I think the best binary->decimal algorithm is subquadratic? something with scaled remainder trees). But I don't disagree: Calculators (as absolutely niche as they are) would certainly be – Marcus Müller Jan 27 '23 at 22:27
  • a good counterexample to my claim. clocks/RTC: color me surprised! I'd assume that 0b111100 would be easy enough to detect, compared to [8421][8421]=0110|0000. – Marcus Müller Jan 27 '23 at 22:29
  • 1
    @MarcusMüller The HP35 calculated CORDIC transcendentals in BCD! (originally, bit-serial BCD at that, IIRC). There's no need for the best sqrt algorithm when the human interaction is what is limiting. – Spehro Pefhany Jan 27 '23 at 22:37
  • 3
    From an article from 1953, *"Coded Decimal Number Systems for Digital Computers"* by Garland White is this quote: "This is the number system chosen by Prof. Aiken at Harvard for use in the Mark III Calculator." John A. N. Lee writes an article called *"Howard Aiken‘s Third Machine: The Harvard Mark III Calculator or Aiken-Dahlgren Electronic Calculator"*. In that article the discussion points out that he chose to represent negative numbers using 9's complement and needed to use "easy complementation" for their drum data storage unit. There's more in the article than that, too. – periblepsis Jan 27 '23 at 22:44
  • @periblepsis Nice find! That paper (doi 10.1109/JRPROC.1953.274330) at least describes claimed advantages of the 2-4-2-1 code. Of course 9's complement is used in 8-4-2-1 BCD calculations for subtraction (and division). – Spehro Pefhany Jan 27 '23 at 22:58
  • @SpehroPefhany An answer here will be coming from you, then? – periblepsis Jan 28 '23 at 00:30
  • @periblepsis If nobody has an example in ~48h, I will summarize including your valuable link and mark the Wiki page as [citation needed]. – Spehro Pefhany Jan 28 '23 at 00:36

1 Answers1

4

There does not appear to be any evidence that Aiken codes are in use in the specified applications "digital clocks, pocket calculators and similar devices".

There is ample evidence that 8-4-2-1 BCD (Binary-Coded Decimal) is in such use, such as the presence of decimal-adjust instructions that correct an addition to 8-4-2-1 BCD after a binary add in such diverse MCUs as Microchip PIC, 6502 and Oki 4-bit mask-programmed MCUs. Real-time clock chips generally use packed 8-4-2-1 BCD (two nibbles per byte). The original scientific calculator HP35 implemented CORDIC transcendental calculations (trigonometric and exponential/logarithmic) using serial BCD.

One might speculate that at some point the general use of BCD was conflated with Aiken codes in particular and then the phrase was repeated and copied verbatim without thought.

Some claimed advantages of Aiken codes are mentioned in the 1953 paper "Coded Decimal Number Systems for Digital Computers" by Garland White (doi 10.1109/JRPROC.1953.274330). The paper is primarily concerned with promoting a 5-2-1-1 scheme (different from both 8-4-2-1 BCD and 2-4-2-1 Aiken codes). From that source, we have this table:

enter image description here

One advantage is that the 9's complement of an Aiken code is generated by simply complementing the bits. This is generally not significant in "digital clocks, pocket calculators and similar devices" since the bit-wise or nibble-wise adder will be reused to subtract each digit from 9 (speed not being an issue in any of those applications).

Spehro Pefhany
  • 376,485
  • 21
  • 320
  • 842