# Is there something special about the number 65535?

2¹⁶-1 & 2⁵ = 2⁵ (or? obviously ?)

A developer asked me today what is bitwise 65535 & 32 i.e. 2¹⁶-1 & 2⁵ = ? I thought at first spontaneously 32 but it seemed to easy whereupon I thought for several minutes and then answered 32. 32 seems to have been the correct answer but how? 65535=2¹⁶-1=1111111111111111 (but it doesn't seem right since this binary number all ones should be -1(?)), 32 = 100000 but I could not convert that in my head whereupon I anyway answered 32 since I had to answer something. Is the answer 32 in fact trivial? Is in the same way 2¹⁶-1 & 2⁵-1 =31? Why did the developer ask me about exactly 65535?

Binary what I was asked to evaluate was 1111111111111111 & 100000 but I don't understand why 1111111111111111 is not -1. Shouldn't it be -1? Is 65535 a number that gives overflow and how do I know that?

• There must be something special. It reminds me of 56 6635, the Czech national standard for beer. Hmmmm...time for a beer. – joshp Nov 22 '12 at 22:35
• You make too many assuptions: 65535 gives -1 only in 16-bit two's complement arithmetic. It gives -0 in 16-bit one's complement arithmetic and 65535 in 32-bit two's complement and one's complement arithmetics. – mouviciel Nov 25 '13 at 8:25
• It is the upper limit of TCP ports. – Renae Lider Oct 5 '14 at 9:48

Answering the second part of your question. You've tagged it as so, 65535 in 32 bits is `00000000000000001111111111111111`, signed or unsigned it is not -1.