Professional Web Applications Themes

Bit shifts in Cocoa - Mac Programming

Does anyone know how to do bit shifts in Cocoa? I have declared an integer and I want to shift it one bit to the right (same as dividing by 2). How can this be done in Cocoa? I already tried "x >> 1", but it did not recognize the ">>" syntax. I'm also interested in information about other mathematical logical syntax in Cocoa. I didn't find anything about that on the apple developer web site. Any help is appreciated. -Korbin...

  1. #1

    Default Bit shifts in Cocoa

    Does anyone know how to do bit shifts in Cocoa? I have declared an
    integer and I want to shift it one bit to the right (same as dividing
    by 2). How can this be done in Cocoa? I already tried "x >> 1", but
    it did not recognize the ">>" syntax. I'm also interested in
    information about other mathematical logical syntax in Cocoa. I
    didn't find anything about that on the apple developer web site. Any
    help is appreciated.

    -Korbin
    Korbin Meiser Guest

  2. #2

    Default Re: Bit shifts in Cocoa

    On 10 Sep 2003, Korbin Meiser wrote:
    > Does anyone know how to do bit shifts in Cocoa? I have declared an
    > integer and I want to shift it one bit to the right (same as dividing
    > by 2). How can this be done in Cocoa? I already tried "x >> 1", but
    > it did not recognize the ">>" syntax. I'm also interested in
    > information about other mathematical logical syntax in Cocoa. I
    > didn't find anything about that on the apple developer web site. Any
    > help is appreciated.
    First of all, your question as asked doesn't make sense. Cocoa is not a
    programming langauge, it is an API. You probably meant Objective-C, which
    is the langauge normally used with Cocoa.

    Objective-C is just C with some OO stuck on. So all the basic math
    operators are the same. Your "x >> 1" statement should work. If it
    doesn't, it's either because you have another error, or you're not using
    Objective-C.

    --
    "From now on, we live in a world where man has walked on the moon.
    And it's not a miracle, we just decided to go." -- Jim Lovell

    Mike Ash - <http://www.mikeash.com/>, <mailto:mailmikeash.com>

    Michael J Ash Guest

  3. #3

    Default Re: Bit shifts in Cocoa

    In article <be168cf0.0309101256.6792012dposting.google.com >,
    [email]cryptofishhotmail.com[/email] (Korbin Meiser) wrote:
    > Does anyone know how to do bit shifts in Cocoa? I have declared an
    > integer and I want to shift it one bit to the right (same as dividing
    > by 2). How can this be done in Cocoa? I already tried "x >> 1", but
    > it did not recognize the ">>" syntax. I'm also interested in
    > information about other mathematical logical syntax in Cocoa. I
    > didn't find anything about that on the apple developer web site. Any
    > help is appreciated.
    It would help if you told us what programming language you're using. :-T

    The languages that have Cocoa bindings that I know of include

    Objective C
    Java
    Python
    Perl
    AppleScript

    and there are probably just as many others. Some of them support
    bit-shifts, others don't. Objective C (which is the language you'll want
    to be using if you're doing anything as advanced as a bit-shift)
    supports the << and >> operators just fine.

    Cheers,
    -- M. Uli Kusterer
    [url]http://www.zathras.de[/url]
    Uli Kusterer Guest

Similar Threads

  1. #39422 [NEW]: Time shifts randomly between GMT and PST
    By daemonist at guildmail dot sojurn dot org in forum PHP Bugs
    Replies: 7
    Last Post: November 11th, 04:23 AM
  2. Colour Shifts with CS
    By Paul_La_Rue@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 0
    Last Post: May 19th, 03:43 PM
  3. Slicing shifts layout....?
    By skin webforumsuser@macromedia.com in forum Macromedia Fireworks
    Replies: 2
    Last Post: September 26th, 03:44 AM
  4. Q About Cocoa & CF Prefs..
    By David Phillip Oster in forum Mac Programming
    Replies: 2
    Last Post: July 31st, 12:04 PM
  5. Text shifts in Netscape
    By elanova webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 3
    Last Post: July 21st, 03:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139