• 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: Unsigned Long Long
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unsigned Long Long


  • Subject: Re: Unsigned Long Long
  • From: Marcel Weiher <email@hidden>
  • Date: Thu, 13 May 2004 19:14:07 +0100

On 13 May 2004, at 15:05, Sherm Pendley wrote:

On May 13, 2004, at 8:31 AM, Clark Cox wrote:

"always" is a dangerous word...

Yep - it's not a word I like to use. I'm just repeating what every text book, paper, tutorial, etc., has told me. And experience has borne it out - every CPU I'm aware of has hardware bit-shifting instructions that are substantially faster than its integer divide instructions, which are generally implemented in microcode.

That used to be true of multiply as well, now we've got CPUs with single-cycle floating point multiply-add instructions. I am not making a prediction that the same will happen with divide, but things change.

No, I'm suggesting that you test the assumption that "GCC doesn't optimize division by a constant power of 2 into a bit-shift on its own"

Why would I want to do that?

Test the assumption or write the code as "divide" rather than shift? I probably wouldn't do the former, unless I notice a puzzling performance problem, as I don't think any 'serious' compiler doesn't do this optimization.

As for the latter, I would *always* want to write the operation I *intend*, instead of substituting a *different* operation that I know has the same effect for a (machine-)specific number representation. That's the compiler's job, and intention-revealing code is something very near and dear to my heart.

Marcel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Unsigned Long Long
      • From: John Stiles <email@hidden>
References: 
 >Unsigned Long Long (From: email@hidden)
 >Re: Unsigned Long Long (From: Fritz Anderson <email@hidden>)
 >Re: Unsigned Long Long (From: Sherm Pendley <email@hidden>)
 >Re: Unsigned Long Long (From: Clark Cox <email@hidden>)
 >Re: Unsigned Long Long (From: Sherm Pendley <email@hidden>)
 >Re: Unsigned Long Long (From: Clark Cox <email@hidden>)
 >Re: Unsigned Long Long (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: Cocoa Programming for Mac OS X (SE)
  • Next by Date: Re: Calling a method on objects in an NSArray
  • Previous by thread: Re: Unsigned Long Long
  • Next by thread: Re: Unsigned Long Long
  • Index(es):
    • Date
    • Thread