• Advertisement

Archived

This topic is now archived and is closed to further replies.

Bit shifts or multiplications

This topic is 5311 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering whether using bit shifts instead of multiplying or dividing by the power of 2^n is worth it. Will it improve performance at all and if so will it improve it enough to make using bit shift for this purpose worth wild. ---- Jemts "A Hooloovoo is a super-intelligent shade of the color blue."- Douglas Adams

Share this post


Link to post
Share on other sites
Advertisement
It''s not worth it. Go for standard multiplication, which is more readable.

Share this post


Link to post
Share on other sites
You will not notice a difference, and if the compiler is even half-smart it should do the conversion for you.

Share this post


Link to post
Share on other sites
Yeah, any compiler will convert a multiplication that is a power of 2 and turn it into a shift anyways, find something better to optimize .

Share this post


Link to post
Share on other sites
thanks alot

----
Jemts
"A Hooloovoo is a super-intelligent shade of the color blue."- Douglas Adams

Share this post


Link to post
Share on other sites

  • Advertisement