Re: Unsigned Long Long
Re: Unsigned Long Long
- Subject: Re: Unsigned Long Long
- From: Clark Cox <email@hidden>
- Date: Thu, 13 May 2004 08:31:16 -0400
On May 12, 2004, at 23:00, Sherm Pendley wrote:
>
On May 12, 2004, at 10:05 PM, Clark Cox wrote:
>
>
> On May 12, 2004, at 21:15, Sherm Pendley wrote:
>
>
>
>> Bit-shifting is faster than division:
>
>
>
> ...but then you make a statement that is also not supported by the
>
> standard.
>
>
I didn't say it was. Nor did I state or imply that it should it be -
>
it's an implementation detail, not part of the language definition.
>
>
Regardless, any introductory programming text or class will tell you
>
the same thing. If you're multiplying or dividing by a power of two,
>
bit-shifting is always faster than integer division.
"always" is a dangerous word...
>
>> Assuming of course that GCC doesn't optimize division by a constant
>
>> power of 2 into a bit-shift on its own.
>
>
>
> That is a bad assumption to make, for something so easily testable,
>
> there is no need to assume.
>
>
What are you suggesting, that I benchmark the bit-shift operators
>
and/or examine the assembly code produced by every compiler available?
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"
>
Is that your idea of "easily testable?" Why would I go to such absurd
>
lengths, when there's a trivially simple alternative that's guaranteed
>
to produce optimal code with any C compiler for any modern CPU?
--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.