In the movie Martian, why does Mark use Hexadecimal to communicate with NASA? Couldn't numerals from 0 to 9 sufficed for indicating the number corresponding to the alphabet?
-
7Well, they're using the full ASCII table, not just the alphabet, so.– Wolfie InuCommented Nov 13, 2015 at 11:19
-
6Strictly speaking, ASCII is only 7 bits, and he has 8, so he could use any character in Unicode (UTF-8 encoded) not just ASCII. :-)– R.. GitHub STOP HELPING ICECommented Nov 13, 2015 at 23:18
-
12@R I'd be impressed if a Botanist with a simple ASCII chart could figure out the proper UTF-8 encoding of arbitrary Unicode characters beyond the basic 128 ASCII characters.– rmaddyCommented Nov 14, 2015 at 1:01
-
115768792073686F756C646E277420493F– MarkCommented Nov 15, 2015 at 4:53
-
5The real question is, why did he use hexadecimal + a question mark instead of just hexadecimal?– ClaudiuCommented Nov 15, 2015 at 17:29
8 Answers
Mark chooses to use a hexadecimal system primarily because his own ability to work out what the camera-pointer is pointing at isn't precise enough. If he has all 26 letters (plus a question card, plus a space), there's a reasonable chance he'll struggle to determine which letter they mean. Add in the numbers 0-9 and it gets even worse. On top of that, if the turn is off by even a couple of degrees, it'll be almost impossible to communicate at any sort of speed.
By comparison, hex cards (plus one extra card to indicate a question) requires just 17 cards, a far more manageable number:
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.
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.
...
So I’ll make cards for 0 through 9, and A through F. That makes 16 cards to place around the camera, plus the question card. Seventeen cards means over 21 degrees each. Much easier to deal with. The Martian: Andy Weir
Obviously in the film, the pointer seems rather more efficient at turning and stopping (which invalidates his reasoning) but that's Hollywood for you.
-
14@Barry he's choosing to use ASCII codes because he and NASA would already be intimately familiar with them, since that's how text is transmitted electronically. Commented Nov 13, 2015 at 12:04
-
15@Barry I'd imagine a conversation between NASA and an astronaut stranded on Mars may want to occasionally contain some actual numbers. The benefit of hexadecimal is that everything is a unique two digit number. If you just use the decimal number system to map to letters of the alphabet, you can't then use actual numbers; does '26' mean the number 26 or the letter Z? Commented Nov 13, 2015 at 13:59
-
4@Barry In this case, Z takes an extra character to represent because every character is space delimited. Using a hexadecimal system that everyone is familiar and comfortable with means that EVERY character, upper & lower case, 0-9, and punctuation, as well as a slew of whitespace characters can all be represented by a single pair of hex characters. This includes using the "null" character (00) to represent the end of a transmission. So, uppercase Z = "5A" and lowercase Z = "7A". A space="20", and a period="2E", etc.– nhgrifCommented Nov 13, 2015 at 14:19
-
13The question is "Why did Mark use a notation with 16 symbols instead of 10 symbols?" You're answering a question that would be "Why did Mark use a notation with 16 symbols instead of 38 symbols?"– MoyliCommented Nov 13, 2015 at 14:44
-
6Richard answered using in-universe information, where the character didn't weigh the options of 16 versus 10; he chose between 16 and 38, and this was the argument for the 16. The spirit of the question is addressed if not the specific comparison, which was not even a considered option in the book. Commented Nov 13, 2015 at 14:48
Here are the major reasons I can think of to prefer Hexadecimal over a (pretty arbitrary) decimal to alphabet mapping:
Hexadecimal and the ASCII character codes should be something NASA scientists are familiar with, so when presented with 16 cards - 0-9 and A-F - the intent is immediately obvious: "I want to communicate using Hexadecimal."
There is no ambiguity. Mapping the 10 digits of the decimal number system to a letter of the alphabet would work, provided you only want to ever use the letters of the alphabet. Being able to use actual numbers would probably be useful in a conversation between NASA and an astronaut stranded on Mars. Hexadecimal means that every letter of the alphabet, every number, and a lot of punctuation and other symbols, can all be uniquely represented by a two digit number.
Hexadecimal would actually be faster to communicate in. If you have to use a 'space' in between each letter, then you're looking at two camera movements for the first 9 (or 10 if you map A to 0) letters of the alphabet, and three movements for the rest. Hexadecimal is two camera movements per character.
-
Although there is no textual source, if one were to ask the author I'm sure reason #3 here would come up. Communicating in hex would just be faster. Plus, if any binary programs needed to be sent, they could just be sent in straight hex. Commented Nov 13, 2015 at 18:15
-
A long time ago, I did a whole bunch of coding in hex. It's not as difficult as it looks if you've done a lot of it. Plus it's very efficient when sending information in a limited bandwidth. Commented Nov 14, 2015 at 2:29
-
If you remove the 32 non-displaying characters, all of 7-bit ASCII can be encoded by 2 digits of 0-9. However, this would require additional communication with NASA to establish a new standard, something Mark didn't have.– WlerinCommented Aug 7, 2016 at 5:31
He isn't a computer scientist. Inventing a new way to transmit all of the text you want isn't going to be trivial.
He could have made a 100 entry table (with values 00 to 99), and assigned each one a character. But then he'd have to communicate the table back to NASA headquarters, and it would take the same number of messages to transmit a character anyhow! (2 messages per character).
Simply sending 01-26 to encode letters isn't very good: encoding numbers would require spelling it out! It gets worse if they need to communicate ?
or !
or .
or ,
or #
etc. (unlikely, but possible)
ASCII is going to be well known to both sides. There is no need to transmit a table. It contains a basic character set that will allow you to pass most technical information (including programming) between one side and the other. On Earth, they'll be able to type up a message in a text editor and transcode it to ASCII by just looking at the raw bytes of the message, and won't have to custom-write software to do it, which makes the problem easy and reliable on their end.
In short, there was already a well-known way to communicate using 2 nibbles per character. Reinventing a new protocol will be error prone and more difficult. Once 1/17th of an arc was large enough to distinguish easily, there is not much benefit to going to less precision, at least initially.
As noted, going to 26 or 36 or higher runs into precision problems (26 letters + 10 numbers + space + 3 symbols = 40, or 9 degrees of arc per character). So transmitting 1 letter per camera move wasn't practical. Doing 2 characters per 3 camera moves would probably be doable, but runs into the "redesign" problem and protocol communication issues.
Meanwhile, sending "Use ASCII", and signs saying 0-9 A-F and a ? solved the problem.
I suspect that part of the reason is that it makes it look more technical and impressive.
In theory, hexadecimal should allow much higher bandwidth - for each two positions of the camera, 1 full byte can be transmitted, with 255 possible characters. In contrast, a decimal approach would only allow 99 characters. However there is nothing (that I can recall) that shows that the extra bandwidth was necessary or even used.
The simpler decimal system could easily include the 26 capital letters, 26 lower case letters, numbers and associated punctuation marks.
The hex approach use relies on the ASCII table - which is usually only 7 bit; only 4 values (out of the full 16) of the first digit are used for printable letters if lower case letters are excluded.
Where the extra bandwidth would have been useful would have been to define a table of most-used words. Mark could easily have written a list of common words and displayed them to the camera. They could have vastly increased the speed of communication, since they would have had a vocab of 12x16 = 192 words to use. Xkcd (https://xkcd.com/1133/) has shown us the very full communication is possible with only 1000 words (10 bits). Having 192 fast words, with full spelling out of any words not in the list, would make communication much less tedious. It also doesn't seem unreasonable for Mark to figure this out and communicate it to Earth. Even just a few words would help.
If he had more paper and some patience, an even better approach would be to use 3 digit hex codes - this would give him 4000 words, plus the alphabet.
Even better would be to adopt some simple Huffman coding - i.e. use shorter codes for frequent symbols. He could put the most common words/letters in the first digit, along with special codes for 2 digit or 3 digit words. This would give varying message length, but would still be very feasible to decode by hand.
But the best approach of all would be to use the computer to work out an optimally compressed set of data, and then just transmit this using the full 8 bit range. This would require somewhat tricky programming that would probably be beyond him - it wouldn't be efficient to use the standard compression libraries since a fixed dictionary approach would be better. This way he could approach the theoretical limit of 1 bit per character, or 4 characters for each positioning of the camera.
But it probably wouldn't be as dramatic for the readers/viewers.
-
1There's actually no need to improve the "manual" mode of communication as they do this just as long to fix the rovers OS to use pathfinder. The increased bandwith of HEX with full ASCII is also highly doubtful as most characters in ASCII will not be used.– GhanimaCommented Nov 13, 2015 at 15:14
-
2They didn't know at the outset that they would be able to get the rover to communicate. The trick with sending data through the logging interface seemed plausible, but convenient... I still think that if I were waiting for the messages to come through at 30s/char or so, I'd be keen to move to a more efficient method pretty quickly. Particularly as I would have plenty of time to think about it. Commented Nov 13, 2015 at 15:52
-
Peter, right. It is pointed out that he kinda got bored writing the camera positions down.– GhanimaCommented Nov 13, 2015 at 20:50
-
If memory serves, they did use some of the more advanced approaches like Huffman encoding... once the guys on the ground helped him link in a more effective means of communication which was less dependent on human interaction... you just don't see it because the computers were doing it for him Commented Nov 14, 2015 at 2:09
-
(I like parts of several other answers and comments, but they all have their issues so here goes...)
"tl;dr"? Just the bold for a concise version.
Note that some answers or comments are about "why not have each pointer position directly correspond to a symbol--not a code at all." The novel quotation (below, and as in Richard's answer) explains that, but the question was simply "why not use numerals from 0 to 9", i.e. decimal instead of hexadecimal. So I'll start by taking ASCII as a given. In an endnote I'll say a little about more efficient schemes for "indicating the number corresponding to the alphabet", to quote the asker, since I guess he meant a code but possibly not ASCII. (And maybe it isn't as clear in the movie, as it is in the novel, that that's the code being used. I don't know, I was a little tipsy when I watched it.)
Answer to the second part first: simply "yes," sending codes in digits 0 to 9 is totally sufficient. In the novel, the quote (thanks to Richard) that explains why to use a limited number of symbols is:
"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."
This makes it obvious: 0 to 9 means fewer cards, so also fine.
To those not mathematically inclined, it might seem to be implied that there is something special about hexadecimal (in which the digits A - F represent 10 - 15 and a digit's position indicates the power (exponent) of 16 instead of of 10) in relation to ASCII, such as in this other quote:
"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."
But no: ASCII is just a table that "maps" a number to a symbol, so that number can as easily be the more familiar decimal with digits 0 to 9.
The first part--"why hexadecimal?"--isn't answered, at least in the film. Probably the best answer is an out-of-universe one: it seems like nerdy science stuff, and this movie loves its nerdy scientists. Hey, it worked for Ron Howard and Tom Hanks.
In principle it is more efficient--fewer moves of the pointer--to have 16 "digits" (pointer positions) than 10. Indeed, the more the better until it becomes too many our favorite Martian to distinguish. Other stackexchangers have described, in varying detail and correctness, other encoding schemes* which could take much better advantage of this, especially for our astro-botanist hero's circumstances. But @Ghanima and @Peter Davidson are the most on point by noting that, by using ASCII as in The Martian, the possible efficiency of having 16 vs 10 digits per pointer move is mostly wasted. To be more explicit about how little difference it makes in the actual case: In ASCII, the numbers that represent each of "space", 0 - 9, A - Z (but not a-z), and symbols except {|}~, are less than 99, so if you don't mind BEING A SHOUTY DICK TO YOUR MARTIAN BUDDY BY TEXTING IN ALLCAPS and can resist "hugging" {{Matt Damon}} (Can you? No, really--CAN YOU?? 'Cuz he's adorable!) you need no more pointer moves (2) per character with decimal than with hexadecimal.
Endnotes:
* Hey Mark, no you don't have to use ascii. Apparently you can communicate to NASA any method you make up that you want them to use. For instance, (still using hexadecimal if thinking numerically) one where the 15 most common letters are each represented by only one "digit" (one move of the pointer), 0 to F skipping 1, and the other 11 by the values 10 to 1A. The value '1' is skipped so that when it is sent it is clear that it is the first digit of a two digit code value.
Like ASCII it is a simple symbol encoding scheme, but the large majority of letters sent will take half as long. Sending numbers is given less priority (it wasn't mentioned in the novel quotes, or the movie I think). Even in ascii, the code point for each digit is a two digit number. So if you want to send a lot of digits, instead of encoding them like in ascii and/or one of the previously posted comments, you'd want to send them as "plain numbers." If a couple extra pointer positions isn't too many, a simple way is to add one that means "what comes next is a number" and one that means "what comes next is not a number." Signalling this without these extra positions (that is, using only code values that could be number data) is left as an exercise for the reader.
More fancy stuff like Huffman coding is mentioned by others but, hey, Mark is just the greatest botanist on Mars--he can leave that to the math or computer nerds at NASA.
** [Pushes nerd-glasses back up on bridge of nose]: actually ASCII uses only 0 - 127, not 0 - 255.
Well, assuming you mean why didn't they just use ASCII code in decimals, instead of using hex?
Technically, they could've, I mean 32 is the space character, 97 is the letter 'a', 117 is 'u' and so on.
So technically, Mark could've just written "ASCII using decimals" on his board to send that message as a picture and then used only 11 other antennas to represent all 10 digits from 0 to 9 and the question mark.
That would've given him a wider range for each letter BUT most of the alphabet letters on the ASCII table are represented with 3 digits (on base 10), so communications would take a bit longer.
That's the only reason I can think that makes sense to me, the time it would've taken them to transmit each letter would've increased the overall communication time.
-
1But now, you get
22
. Is it v, the 22nd letter? Or is it122
and you only failed to spot1
? Or is it the numerical 22? With ASCII, you have mistakes easier to spot and wider range of things you can say without doubts - and all that with 2 moves instead of 3, so 33% less chance to make mistake in some characters. You can read text with some characters randomized, but 33% less is always easier.– MołotCommented Nov 13, 2015 at 14:27 -
You mean with HEX right? because I'm not saying he shouldn't have used ASCII, all the opposite actually, all I'm saying is he could've very well represented all ASCII characters with the decimal numbers, he would've only needed more moves. And I think I understand your other point, he wouldn't know if each letter was a 2 digits character or a 3.. if that's probably the right answer. Commented Nov 13, 2015 at 15:43
-
Most reference charts for ASCII organize the characters in a table of 16 columns and 16 rows (well, strictly speaking only 8 rows; or maybe like this historic example in 16 rows and 8 columns) that makes it especially easy to decode/encode from/to hex digit pairs.
However you slice it, 17 cards give him 17 symbols, be they letters or numbers. The only advantage of hexadecimal is that the symbols for 10 through 16 are arguably narrower in hexadecimal (A - F). If the card spacing is what counts, there is no advantage at all. It sounds good, but it is nonsense.
-
Hi, welcome to SF&F. It's really not clear what you're saying. Are you suggesting that the cards should be numbered 1 - 17? The question is why 16 (17) cards and not 10 (11)? Did you read all the previous answers? It is not "nonsense."– DavidWCommented Apr 26, 2020 at 3:51
-
I'm saying that 16 cards gives you 16 letters, regardless of how you represent the letters. The first 16 letters in the alphabet are A B C D E F G H I J K L M N O P In base 10 this can be coded 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 In base 16 (hexadecimal), it would be 0 1 2 3 4 5 6 7 8 9 A B C D E F The ascii code is (in base 10) 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 You can use any of these symbol codes you like, but you still only get 16 letters. I have read many of the previous answers, but not all of them. If I have missed something important, please let me know. Commented Apr 26, 2020 at 4:29
-
DavidW, btw, thanks for your reply. I should add that I like the movie a lot, and I think that in general it portrays science very well. But I've never found a sensible explanation for this particular byplay (the hexadecimal alphabet cards). Commented Apr 26, 2020 at 4:51
-
@DavidW sorry but this answer was very concise and correct. Hexadecimal was nonsense and there's no simpler way to put it than 17 cards is 17 symbols. If I were bandwidth limited I'd assign a card two letters. It's highly unlikely both letters will produce a message. Hexadecimal just guarantees extra camera movement to get any message. Commented Feb 22, 2022 at 8:18