42 and Binary Coded Decimal - Computerphile

Share this video on

What's Hot

What's New

Top Grossing

Top of the Chart


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.

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 ;)

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.

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

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

AngryMurloc : 42 || !42 - William Shakespeare

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.

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

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

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

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

Suvi-Tuuli Allan : I am a robot.

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. :-(

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.

Aokis : Hehe 42 comments

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

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

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

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

Jim Griffiths : *

Penny Lane : Decimal floating point next?

Tom Mulligan : I fancy a nybble

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.

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

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

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.

information to learn : Interesting!😎 Saving the video in the computer and network file.

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

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

Reji Domus : These stories are pure gold.

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

Rick Pat : I don't get it. What is the need for prepending 4 bit before printing?

Young thug : I can't understand anything but I love his voice

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

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

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?

TrivleX : waddup my nibbles

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.

Creative & Random : deep thot

Confused Wolf : whoa!! excellent sunny shirt!!

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

mwalsher : There have been so many inconsistent, differing, varying, and changing methods (despite "standards"), that it is a small miracle that anything actually works correctly at all today. (Casual Brailsford; it must be summer. Yay.)

Tyler The God : Ok

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...

Olaf Doschke : Did I already mention this in another video? Motorola's 68000 CPU had the assembler instruction ABCD - Add Binary Coded Decimal.

bepowerification : haha.. just tried to use the programmers calculator view in windows 7 to look what it thinks about 0,1 and hey surprise, the , button is disabled..

Artpholomule Nutt : BCD sounds like a particularly nasty venereal disease.

Runge Kutta : so that's where gluon comes from!

AmirAli Tn : Also 0x42 in ASCII is B. As in Be... _mind blown_

kpunkt klaviermusik : Is there something like a number format with variable bit length? There are so many formats (integer, word, signed, unsigned, float, double, quad), but there are always numbers, that cannot be stored exactly. A BCD format with variable bitlength (up to millions of decimals) would be really helpful.