Ch4 Bronze Challenge


#1
  1. What is the binary representation of -1 using an 8-bit signed integer?
    My answer: 11111111
    Reason: The bits that are turned on are -2^7, 2^6, 2^5, 2^4, 2^3, 2^2, 2^1, 2^0. Add them all up, and I get to -1.

  2. Taking the same bit pattern, and interpreted it as an 8-bit unsigned integer, what’s the value?
    My answer: 255
    Reason: This time the bits represent 2^7, 2^6, 2^5, 2^4, 2^3, 2^2, 2^1, 2^0. Add them all up, and I get to 255.

Thank you in advance for correcting me if I’m wrong.


#2

That’s what I got. Great write-up!! 255 happens to be the max number print(UInt8.max)


#3

Thank you very much this explains so much more than I understood before. I am new to programming and this was keeping me from progressing.