Is there something special about the number 65535?

Posted by Nick Rosencrantz on Programmers See other posts from Programmers or by Nick Rosencrantz
Published on 2012-11-22T19:49:51Z Indexed on 2012/11/22 23:09 UTC
Read the original article Hit count: 531

2¹6-1 & 25 = 25 (or? obviously ?)

A developer asked me today what is bitwise 65535 & 32 i.e. 2¹6-1 & 25 = ? 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¹6-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¹6-1 & 25-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?

© Programmers or respective owner

Related posts about numbers

Related posts about binary