51

OK, I feel stupid asking this - but in Jeff's article: Getting the Interview Phone Screen Right and originally stated in the 5 essential phone screen questions:

They shouldn't stare blankly at you when you ask with 2^16 is. It's a special number. They should know it.

I've been a developer\software engineer\code monkey\whatever for a little while now, and I don't think I've ever come across this. I mean, I can certainly count binary values do basic operations on them, etc, etc. But I don't see what is "special" about this value.

javamonkey79
  • 875
  • 2
  • 10
  • 13

3 Answers3

84

(216 - 1) or 65535 or 0xFFFF or "64k" is the maximum value of 2 bytes. For a long time CPUs used 16-bit architecture and OSes were likewise based on 16-bit operations and "words". There were 16-bit commands and 16-bit memory addresses. A lot of systems/compilers still use 16 bits for integers.

So, (216 - 1) is special because it is the largest number that a 16-bit (unsigned) integer can hold and the largest memory address that a 16-bit architecture can access.

Travis
  • 1,861
59

From the full body from Steve Yegge's article,

Candidates should know what bits and bytes are. They should be able to count in binary; e.g. they should be able to tell you what 2^5 or 2^10 is, in decimal. They shouldn't stare blankly at you when you ask with 2^16 is. It's a special number. They should know it.

I was thrown off from the bit you quoted in the question; it sounded like a candidate should be able to describe it's significance, but in context he's saying that candidates should know, off the top of their head, what the decimal conversion of 216 is.

The significance of this is that since we humans still use decimal for counting, especially in our heads (in most circumstances), we need to know the rough capacities of the common byte blocks that we use for storage, memory, or even character encoding. Since a byte is 8 bits, the most common are 8, 16, 24, 32, and 64.

At the present time I would say 232 is the most commonly occurring capacity a developer deals with. I am suspicious of developers who don't know that 232 is roughly 4 billion (max value of ~2 billion if signed), since it means they've never bothered to find out roughly how many records can be stored in their databases that use 32-bit ints for primary keys, or when old code using 32-bit ints for IDs, dates, etc. will need to be refactored to 64-bit.1

216 is the total capacity of the Java short. (Total numbers between -215 and 215-1)

A developer should know by heart what 8-bit is. Among the many common usages is ASCII character encoding.

I wouldn't expect a programmer to know 214 or 218 at all, but I would probably expect that they know 216 since it's a very commonly occurring number and short enough number (65536) to easily remember the full number.


1: If you browse the leaderboards of Call of Duty: MW2 or iPhone Game Center you'll often see cheaters at the top with high score values of 2,147,483,647, which is 231-1, the max value of a signed 232 integer.

Nicole
  • 28,243
3

The only reason I can see for regarding 216 as "special" is because it's one more than the highest integer you can store in a single register on a 16 bit operating system.

Similarly you could apply the same logic to 232 and 32 bit operating systems.

I'd need to know more context for the question before being able to say whether it was a significant piece of knowledge or not.

ChrisF
  • 38,948
  • 11
  • 127
  • 168