# What advantage does the hexadecimal numeric system have over the decimal system in The Martian?

In The Martian, we learn that Mark communicates with NASA using the abandoned Pathfinder from 1996.

At first he uses a YES/NO system to communicate then chooses the hexadecimal system to communicate ASCII coded characters.

I know it is easier to divide a circle to 16 slices, without the need of an angle measuring tool (22.5 degrees per slice). But, wouldn't the decimal system (36 degrees per slice) be more convenient for both him and NASA, even if he does not draw 10 perfect slices?

I mean, wouldn't there be more room for error in rotating the cameras towards the wrong digit with hexadecimal system, than it would be for the decimal, given the size of each slice?

What advantage does the hexadecimal system provide that the decimal system does not?

• I don't remember the book perfectly, or whether he was thinking of this before he set up the hex system, but in the end having the hex made it possible for them to send him compiled programs, right? Jan 4, 2016 at 14:44
• @ToddWilcox - Yes. The quote from the book is "We’ll need to talk faster than yes/no questions every half hour. The camera can rotate 360 degrees, and I have plenty of antenna parts. Time to make an alphabet. But I can’t just use the letters A through Z. Twenty-six letters plus my question card would be twenty-seven cards around the lander. Each one would only get 13 degrees of arc. Even if JPL points the camera perfectly, there’s a good chance I won’t know which letter they meant."
– user7812
Jan 5, 2016 at 0:24
• "So I’ll have to use ASCII. That’s how computers manage characters. Each character has a numerical code between 0 and 255. Values between 0 and 255 can be expressed as 2 hexadecimal digits. By giving me pairs of hex digits, they can send any character they like, including numbers, punctuation, etc. How do I know which values go with which characters? Because Johanssen’s laptop is a wealth of information. I knew she’d have an ASCII table in there somewhere. All computer geeks do."
– user7812
Jan 5, 2016 at 0:24
• "I have to be watching the camera when it spells things out. It’s half a byte at a time. So I watch a pair of numbers, then look them up on an ASCII cheat sheet I made. That’s one letter. I don’t want to forget any letters, so I scrape them into the dirt with a rod. The process of looking up a letter and scraping it in the dirt takes a couple of seconds. Sometimes when I look back at the camera, I’ve missed a number. I can usually guess it from context, but other times I just miss out.".
– user7812
Jan 5, 2016 at 0:26
• @Richard, Related? Exact duplicate if you ask me. Also, the quotes you list are also described well in the movie itself with the exception of him using paper an pencil rather than scratching around in the dirt. Jan 5, 2016 at 15:56

First, the degrees being too narrow is a non-starter. The stick he uses for the 22 degree markers provides the accuracy, and a wider circle would compensate for the smaller, 13 degree sections. And the Pathfinder Lander (renamed the Carl Sagan Memorial Station) IMP (Imager for Mars Pathfinder) would absolutely be able to accurately match any arbitrary degree of rotation. A quality Servo can have a position accuracy in the sub-degree range!

That said, the main reason that Mark uses Hexadecimal is that he needs a way of communicating with NASA that someone will know, without having the luxury of being able to communicate with them how. It's a Chicken or Egg problem. There is no standard base-10 language set. But Hexadecimal is used throughout computers everywhere, and by luck one of the other astronauts had a table on their laptop that Mark could use. Without that table, he would have had to create something from thin air, and hope that they could reply back in a reasonable manner. The ASCII to Hexadecimal was an already established protocol that they could both easily use without having to make something up from scratch, and the Table provided it.

Mark to Camera: I figured one of you guys kept an ASCII table lying around. And I was right. Ladies and gentlemen, I give you super-nerd Beth Johanssen.

Followed by a nameless Engineer immediately understanding it.

Engineer: I know where he's going with this.

Any nonsense about not being able to send numbers or punctuation using a decimal notation is ridiculous, as both numbers and punctuation can be spelled out, and Mark and NASA engineers could work out short hand to prevent needing to spell out longer words.

Of course the Movie Portrayal is fairly non-realistic. Why would any engineer bother with a relatively hard to read multiplication table instead of the much more common linear table, which tend to have Hex, Octo, Decimal, and AlphaNumeric side by side. Why bother with a Question Mark when Hexadecimal has a Question Mark in it (0x63) AND they don't even bother to use punctuation when they send him anything. They also didn't use a space, leaving Mark to figure out what they mean by context.

• Comments are not for extended discussion; this conversation has been moved to chat. Jan 25, 2017 at 17:19

After reading an answer to the exact question on Science Fiction & Fantasy Stack Exchange (as pointed by Richard), it became very clear why hexadecimal is the better system to communicate with.

The reason has little to do with the number of slices in the circle, but mainly with the pre-agreed upon protocol of communication.

You see, using a decimal system means that each character in Ascii would require 3 digits to represent. While hexadecimal can represent any character in 2 digits.

Also, the hexadecimal will make it easier to distinct and to decipher than decimal.

Consider the following sequence of decimals: `072101108108111`

The above stand for:

``````072 -> H
101 -> e
108 -> l
108 -> l
111 -> o
``````

but it could easily be mistaken by:

``````007 -> ?
210 -> "
110 -> n
810 -> ?
811 -> ?
1   -> ?
``````

Whereas in hexadecimal, that sequence would be: `48656c6c6f`

First of all, the number of digits a down by a third, and second, the margin of error is reduced by a large extent.

• That's non-sensical. You would zero pad the decimal notation just as you would with hex.
– cde
Jan 4, 2016 at 12:42
• Like why would he confuse or repeat a zero at the start? Couldn't he just as easily confuse or repeat the 4 at the start and get 44,86,56,c6,c6,f ?
– cde
Jan 4, 2016 at 12:53
• @cde No it's perfectly sensible. To send a single letter in base10 requires ceil(log_10(128)) = 3 separate transmissions (rather obvious: every single letter has to be transferred). If you use any base larger than 11 you can reduce this nicely to 2 required transmissions. Or basically yes you would have to zero-pad every decimal value which would mean 50% more transmissions for the same result.
– Voo
Jan 4, 2016 at 19:34
• @voo throughput wasn't really Mark's concern. It wasn't mentioned in the book or movie. The practical difference would have been a few seconds per message, a human scale difference that wouldn't matter.
– cde
Jan 4, 2016 at 21:59
• @cde throughput absolutely is a concern. There's a scene in the book showing Mark deciphering messages because NASA omits space and some consonants to speed up communication. And even if it didn't matter, no engineer worth their salt would ever design a system that's 50% less efficient than it could be without any gains (or want to stand outside 50% longer for no good reason)
– Voo
Jan 5, 2016 at 5:31

The hexadecimal system would only use 2 "bytes" per character. With the decimal system there could be letters or symbols requiring 3 "bytes" per character. If you want to avoid confusion and add a 0 in front of characters requiring 2 "bytes", you effectively add 50% to the communication compared to the hexadecimal system.

Plus, since Johanssen has an ASCII table laying around, chances are it contains both the decimal, octal and hexadecimal value for each character. This makes it easy to use an established system of communication.

• Don't use the term "bytes" in this context; it's begging for confusion. Jan 4, 2016 at 21:16
• No, it didn't. The table Mark found only had seven bit binary and Hex, no decimal or octal notation. And it looked dumb
– cde
Jan 4, 2016 at 21:53
• A 4-bit value is called a 'nyble' (or nibble or nybble). A byte is two nybles. Nerds love their word play. Jan 5, 2016 at 10:32
• The hexadecimal system uses half a byte per character, since a single hexadecimal character can be represented using 4 bits (and 1 byte = 8 bits). An ASCII character, which consists of 2 hexadecimal characters, has a size of exactly 1 byte. You state that a hexadecimal character uses 2 bytes, which is four times more than reality. Jun 23, 2017 at 13:02
• I stated the hexadecimal character uses 2 "bytes", not 2 bytes. As Russell stated in the first comment, to avoid confusion, I shouldn't have used byte, but instead nibble (thanks Persixty). Jul 3, 2017 at 20:06

Errors in the stream are also far more obvious with hex than with decimal. For example, if you get the following stream of characters, you know something is wrong:

141424344...

Numbers fall into the hex range 30-39, uppercase letters are 41-5A, lowercase are 61-7A. Space is 20. If you get a two-character sequence that does not start with 3, 4, 5, 6, or 7, or is not "20," then you know the sequence has an error.

But if you shift that sequence forward one character (ignore the leading "1"), it makes sense again: "ABC." You can assume the first character got garbled in transmission and is lost, but the rest of the transmission is readable. It would be far more difficult to do that with decimal.

• Decimal would be simpler. If the first character of 3 isn't 0, 1, or 2, then something went wrong. Also they didn't use the space character, or any other punctuation.
– cde
Jan 5, 2016 at 1:29

16 positions is much easier for a human to read at a glance than 10 would be. A compass rose is a 16-position system (N, NNE NE, ENE...). Now try to think of a commonly used circle divided into tenths. There really aren't many, and we aren't as used to reading them.

There's a subtler advantage to hex ascii: the highest bit will never be set. If you see a hex digit greater than 7, it must be tge second digit of the chsracter. That gives you a quick way to realize you dropped a digit while transcribing, since half the second-nybble digits will be 7 or greater.

But, yeah, it's mostly a matter of "us geeks already know a suitable code; many of us could recreate most of it from memory., it'll be really easy for the machines to handle... why not."

• Well... technically, in the film (and book) there are 17 positions... I'm not certain how fewer positions is more difficult than more positions... Surely four is easier than 8 is easier than 16... Jan 4, 2016 at 22:47
• Fewer is easier to read but takes mor steps tobsend the same info. It's a comprimise trying to find the balance between concision and error-resistance (where the latter also includes human fatigue). Jan 4, 2016 at 22:55
• Is it worth noting that Mark regularly 'drops' some of the digits when he's transcribing them from his memory onto the ground?
– user7812
Jan 5, 2016 at 0:33
• @Richard: Yep. Design around the least reliable component -- the human. Jan 5, 2016 at 6:42

As was said in most of the other answers, hexadecimal (and, more generally, base-2^n) numbers are THE standard in all things computer.

But there is another practical reason: when designing a system of communication involving humans, one wants to maximize throughput while minimizing the possibility of human error. And in terms of human error, hexadecimal notation is a lot more convenient when converting to ASCII, because since each character is one byte long, in is represented by precisely 2 hexadecimal digits. For comparison, in decimal a byte would be about 2.408 digits per byte in the case of continuous streaming (which would vastly increase human error), or 3 when encoding each character separately (which decreases throughput while still increasing probability of error, as one has to then convert the digits to a number afterwards and match the numbers to a linear table instead of using the more natural 16x16 ASCII table where the first digit is one coordinate and the second digit the other). Additionally, this perfect match eliminates the question of which mode of transmission to use (continuous or per-character).

• The standard used to be octal, back when word and byte lengths were more variable... but once we locked into 8-bit bytes, hex took over. Jan 5, 2016 at 6:44
• My first exposure to assembly code was that of DEC's PDP11 line of computers. With its 8 "registers", octal notation made good sense... Still remember `014747` as `mov --r7 --r7` This had the effect of replicating itself from its start address to address 0. Was good for erasing core RAM preventing the next student from simply copying working code for assignments and claiming it as their own. Apr 21 at 23:47

All that is well and good but please tell me how this wouldn't be simpler to transcribe. It's what i thought of when he first started to work it out in the movie: 1. Using the numbers 5,4,3,2,1... create your own "ASCII" style table with 52 letters, 20 digits, required punctuation and space. You have 120 combinations right there if I am not mistaken. So 11111 could be A. 11112 could be B. Point to a number and pause 2 seconds then and spin camera 360 degrees and then point to next number to ensure repeating digits are recognized. If the camera has vertical panning capabilities, have it go up then down for all spaces. This would reset every word at least to help with missed letters.

So I only need 5 signs to point to which is way easier to follow than 16 or whatever. Plus I have more "compression" so quicker transmissions.

Write it on a sign and let them take a picture of your instructions. What am I missing?

• What you're missing is that you suggest inventing a completely new language, then, without the use of any language, teaching that language to others, as a simpler solution than using an established, standard language. Also, since you have to stop and distinctly send each digit, you are talking about using 5 digits for each letter, instead of two, which means you've slowed down communication so you can only send 40% of the information in the same amount of time. Sep 7, 2016 at 13:47