• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: bitwise operations in obj C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bitwise operations in obj C


  • Subject: Re: bitwise operations in obj C
  • From: John Stiles <email@hidden>
  • Date: Wed, 17 Oct 2007 09:54:19 -0700

Make increment a power of two, and then you can use bit masking (via the & operator).
FWIW I would not worry about one division unless Shark tells you that it is a problem. It's not free, but it's not that expensive either.



On Oct 17, 2007, at 9:34 AM, Erfan Aleemullah wrote:

hello all,
I have a modulus operation in my code and it runs fine, but my original
algorithm avoided division all together for speed reasons - I am using
modulus due to a change in requirements.


How exactly (or can I) use bit operations to achieve the same effect and
increase my speed here ?


Code:

line_Number++;

if(line_Number % increment == 0)
// lineNumber is any integer
value > 0, can get large w/ time - 100,000++
{ // increment is user selectable
integer from a set of given values
....
....
}


thanks.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40blizzard.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >bitwise operations in obj C (From: "Erfan Aleemullah" <email@hidden>)

  • Prev by Date: bitwise operations in obj C
  • Next by Date: Panels do not respond to keyboard (NSOpenPanel, NSSavePanel)
  • Previous by thread: bitwise operations in obj C
  • Next by thread: Re: bitwise operations in obj C
  • Index(es):
    • Date
    • Thread