Stephen Kochan's Book Help

Discussion in 'iOS Programming' started by lee.anderson, Jul 15, 2009.

  1. lee.anderson macrumors regular

    lee.anderson

    Joined:
    Aug 28, 2006
    Location:
    UK
    #1
    I've become pretty stuck in "Programming in Objective-C" by Stephen Kochan.
    I do know the author is a member of this forum, so im hoping maybe I will get a reply off him :D

    Im on Chapter 4 with bitwise operators. I have just become completely stuck on this concept. The further I get in the chapter, the more lost I get.
    I have tried googleing and looking through topics on this, but I just can't seem to grasp it...

    I don't want to skip this chapter because I know i'll probably need it in the future so I might as well learn it now.

    Im hoping someone here would be able to show me some links that would help me, or try and explain it a bit easier. I feel so dumb :p
     
  2. jpyc7 macrumors 6502

    Joined:
    Mar 8, 2009
    Location:
    Denver, CO
    #2
    Well, you don't say which concept you don't get exactly.

    I hope you understand that a 1 (one) is equivalent to the logic value True and that 0 (zero) is the logic value False. And that you know the binary logical operations (AND, OR, XOR) and the unary logical operation (negation).

    Then, if you take a single sequence of ones and zeroes, you can then do an unary operation on each position in that sequence. If you have two equal-length sequences, you can do binary operations on each position. If your two sequences are of unequal length, you can extend one of them with zeroes (at the beginning) to make them equal length. So the three-digit sequence 011 is equivalent to the four-digit sequence 0011 (by prepending a zero). (Same concept in decimal math, you can have a number 14 equal to 000014.)

    Anyway, for binary operations (i.e. an operation that needs two operands), you just take each bit starting from one end or the other from each of your two sequences, figure out the result of that operation, and write that down in a result sequence.

    As for links, wikipedia has an article on bitwise operation. I see that I didn't cover the shift operations.

    By the way, you actually probably won't use bitwise operators very often unless you are encoding information in your program in bits.
     
  3. lee.anderson thread starter macrumors regular

    lee.anderson

    Joined:
    Aug 28, 2006
    Location:
    UK
    #3
    Thanks jpyc7,

    This is my first venture into programming, its quite daunting learning all this at once. I know I should really learn a simpler programming language to start with, I'm having a hard time trying to get in a machine/logic thinking pattern. I understand Binary numbers in the simplest sense, but its hard to put it all together.

    There's something Im missing, the chapter goes straight from operator precedence to binary numbers and bits. Im going to read the chapter again to see if Im missing anything.

    Sorry about being so stupid with all this :eek:
     
  4. skochan macrumors regular

    Joined:
    Apr 1, 2006
    Location:
    California
    #4
    Hi,

    I've discovered that the bitwise operators do come as a shock to the system to newer programmers. In the next edition, I will try to provide some more hand-holding when the topic is covered.

    In the meantime, go over to my forum at classroomM.com/objective-c.
    There's a stickied topic there about this subject, in addition to help for any other stumbling blocks you may encounter along the way.

    Here's a direct link to the topic in question:

    http://classroomm.com/objective-c/index.php?topic=217.0

    Cheers,

    Steve Kochan
     

Share This Page