Binary Coded Decimal (BCD) & Douglas Adams' 42 - Computerphile

Share this video on

What's Hot

What's New

Top Grossing

Top of the Chart


RUSKiE : The ASCII equivalent of 42 is asterisk. The asterisk is used in computing to represent 'anything'. So the answer to life, the universe and everything is anything ;)

ProfDaveB : Yes, I just wanted to show that "Computerphile" presenters other than Dr Bagley are also allowed to wear Hawaiian shirts! This particular one was bought about 8 years ago at Macy's, in Stanford University's Shopping Mall.

Brendan McCabe : There are 10 types of people in the world 1. those who understand binary 2. those who don’t 3. those who didn’t expect this joke to be base 3

Xilefian : I was programming some stuff with binary coded decimal the other day. It's still used for real-time clock chips! If you want the bare-metal low level time from these chips they give you BCD, presumably because it's easier to print BCD out to cheap digital displays than to convert an integer to a string. EDIT: Yep you mentioned digital clocks at the end of the video! Very excellent.

Greg Hartwick : Professor Brailsford, NEVER STOP telling us stories about computers and computing. I could listen all day.

LMacNeill : The fact that there is no exact representation of 0.10 in binary has actually killed people. No joke. In the first Gulf War (1990-91) the Patriot missile system was used to shoot down Soviet-made Iraqi Scud missiles. These missile systems clearly had to have very precise clocks in order to know exactly how fast their targets were moving, so that they could know where the target would be by the time the Patriot missile arrived, so it would be in the immediate vicinity of the target when it exploded -- thereby destroying the target in the process. But the initial release of the software in the Patriot missile system had a flaw. Because 0.10 cannot be represented precisely in binary, it's clock would get off by a tiny bit every tenth of a second. If you rebooted the system every 8 to 12 hours, it was never enough of an error to make a big difference. But one particular Patriot installation, protecting a U.S. military barracks in Saudi Arabia hadn't been rebooted in several days, when Iraq fired a Scud missile at it. The Patriot system didn't even fire its missiles because its internal clock was so far off that it simply lost track of the incoming Scud. 28 American soldiers were killed and approximately 100 more were injured, simply because 0.10 cannot be represented in binary, and the programmers didn't realize how big a deal a tiny fraction of a second would be, when added up over many thousands of seconds. :-(

Slithy : "Heavyweight macho calculations". I love it.

Vyl Bird : The exact wording is important. The Deep Thought was specifically asked "What is the answer to the ultimate question of life, the universe and everything?" The answer it eventually gave was 42. It was not, however, able to compute the ultimate question itsself, to which 42 was the answer.

Giles Bathgate : If only they had continued and made 4bits = nibble, 8bits = byte, 16bit= munch, 32bit = gobble, 64bit = meal.

Isabella Bihy : I decided to learn how to tame computers fairly early in life. No, not the cute ones, the desk top computers, which used to be called the "toy department" where I worked. I fell in love with the huge machines at the age of thirteen. By then, there were card punches and card hoppers and a chain printer that sounded like a couple of machine guns going off at the same time. When I went to college in the late 1970ies there were all of those wonderful things, punches, hoppers and this printer. I was happy. Even when I dropped a deck of cards with program code on it. Of course I had spared myself having to punch line numbers. I have experienced the big changes in main frame architecture, from 16bit to 32bit, terminals instead of card decks, the looming software desaster of Y2K, the change from 32bit to 64bit, well, the details passed me. In my early years at work I learned to read machine code, which is helpful analysing bugs, and to program temporary fixes in machine code. It is so nice to see and hear someone explaining the origins of computing. There are still a few dinosaurs of the computer age around, but they are threatened by extinction. Shortly before I went into early retirement, I worked on a client project where one of the required skills was "main frame", programming languages and other software.

AngryMurloc : 42 || !42 - William Shakespeare

John Francis Doe : Your quote of the dialogue was incomplete. The sentence uttered by deep thought before the answer was slightly longer. But the recipients of the output didn't know what the question was, so they commissioned the building of planet Earth to compute the corresponding question.

RMoribayashi : HP scientific calculators all used BCD so avoided the rounding problems inherent in a true binary calculator. In 2004 Thomas Okken's released his exellent HP-42 simulator, Free42. It comes in both BCD and the slightly faster floating point binary versions. SwissMicros brought it full circle in 2017 when they released the DM-42, a physical calculator based on the HP-42 but using a modified version of Free42 for it's firmware. And yes... it uses BCD.

De naaits : Why weren't my teachers more like this guy?! Hats off to the knowledge and experience.

Penny Lane : Decimal floating point next?

avi12 : 4:52 "Because... the average person wants their answers out in decimal, not hexadecimal" Like!

Mister Hat : Why not use an integer number of cents to represent money? Then there's no problem with incorrect rounding.

Zacharie Etienne : There are 10 types of people in the world 1. those who understand binary 2. those who don’t 3. those who didn’t expect this joke to be base 3

Aokis : Hehe 42 comments

Tom Mulligan : I fancy a nybble

tabaks : An episode on FUNDAMENTAL differences between AI and classical programming would be GRAND! Basically, for the lay person, why AI isn't just a giga-complex classical programming effort that is pre-loaded with all possible outcomes...

CyanGaming | ᴹᶦᶰᵉᶜʳᵃᶠᵗ ⁻ ᴳᵃᵐᵉᴾᶫᵃʸ : BCD makes multi-digit 7 segment displays easier :D

BOOZE & METAL : 6502 cpu has a bcd mode , you can turn it off and on and it doesn't take any extra time. I never knew what could it be used for but now it makes sence. Funny thing that nothing stops you from putting numbers that have digits higher than 9 (0xAF for example) and the result of math operations on such numbers is interesting

Reji Domus : These stories are pure gold.

Tony Colle : I love these journeys into history. It's actually very important to have some knowledge of these topics so people who want to be Computer Scientists and not just programmers (although there is nothing wrong with the profession) know how we got to where we are and where we might be heading in the future. Is there some chance that Professor Brailsford or someone can do a session on packed decimal? That is the technology on which so much of the financial world was built and still lives today.

Eric ON : Deep thought wasn't earth. The earth was made as another computer to answer the question for real.

EscapeMCP : Speak up. I can't hear you over that shirt. :)

Patrick from Vienna : I don't get it. What is the need for prepending 4 bit before printing?

Jan Sten Adámek : Fun fact: all x86 processors have instructions for BCD and they have one-byte opcodes because someone though that they would be used very often.

Antonio Rocha : Thank you sir. I always appreciate your brilliant way to express your vast knowledge.

Menachem Salomon : How efficient is multiplication with BCD? I ask because the Intel x86 line allows for BCD addition and subtraction, with "adjustments" and a flag to handle the overflow into the 0xA-0xF space. But for multiplication and division, the operands have to be converted to binary first, and the result back into BCD afterwards. (The FPU can load and store BCD, but internally arithmetic is done in binary.) Is it just the manual method performed in hardware?

Robert Zanatta : Some microprocessors had rudimentary BCD opcodes, such as the Intel X86.

K van der Veen : I expected at least a mentioning of the double dabble algorithm.

TrivleX : waddup my nibbles

Confused Wolf : whoa!! excellent sunny shirt!!

# : Answer to the Ultimate Question of Life, the Universe, and Everything !

Kyle W : Earliest comment yet! also that shirt!!

TheWildJarvi : I built a BCD in -> Binary Out (16bit) in Minecraft hahaha. Its as small as it can be.

pcuser80 : The Z80 had a special instruction for convert the A register to BCD. DAA (Decimal Adjust accumulator)

Creative & Random : deep thot

Suvi-Tuuli Allan : I am a robot.

informationtolearn 11 : Interesting!😎 Saving the video in the computer and network file.

Escanor : I can't understand anything but I love his voice

Tyler The God : Ok

Jim Griffiths : *

flyguille : BCD a tech of the past, where each bit is precious. Todays, is a dissaster waste of resources.

Ognastay M : Sort of: Deep thought: The ultimate "answer" to the TLTU&E *is* 42. The reason why humans couldn't understand it is because they didn't know the ultimate "question" to TLTU&E. Since Deep thought couldn't calculate the ultimate question, earth was created to calculate that. Earth: [4.5 billion years later] the ultimate "question" to TLTU&E is... (just nanoseconds from earth completing its calculations, the vogon space fleet destroyed it to make room for the intergalactic highway) Magraethea (Earth 2.0): since Arthur Dent is the only surviving earthling and element to the ultimate "question", his brain could be used to reboot the program.

Jon Mayo : IEEE 754-2008 standardized a decimal floating point format, which is related to BCD. Many programming languages (Java, C#) support decimal floats as well, but often they have to do pure software emulation as much of the mainstream hardware is limited to only the older binary floating point format from an earlier IEEE 754 standard, with all of its weird rounding issues.

LoneTech : For comparison, there's also FIO-DEC that didn't quite make it this easy (1-9 were precisely those values, but the digit 0 was code 20 octal, or 10000 binary). Decimal types nowadays frequently use word cutoffs rather than digit cutoffs, which can fit e.g. 9 digits in 32 bits or 19 digits in 64 bits.

superscatboy : When I was young and naive, I wanted to work with huge integers in QBasic (to calculate large Lucas numbers) and inadvertently reinvented a highly inefficient BCD system. It was ugly and slow, but it worked goddammit. Still one of my proudest moments in a strange way. I still have a printout of a 20000 digit Lucas number I generated with that nasty bit of work.