Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / C++ / C# - Should I use bit shifting to divide/multiply powers of 2?

Author
Message
prasoc
17
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 27th Jul 2009 23:54
Will it save so many cycles that it actually makes a difference, for example if I do this



instead of dividing by 2 every frame? And what about if I change like 10 divides and 10 multiplications to bit shifts every frame, how much will that improve performance?


Your signature has been erased by a mod
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 28th Jul 2009 02:47
In DBPro, the difference will be almost non-existant. You should concentrate on optimizing the bottle-necks of the code, not things like that which will not be noticeable.

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 28th Jul 2009 08:35
And if you're using C++ the compiler will most likely do the optimization for you anyway, providing you have it enabled.

Homey the Clown
22
Years of Service
User Offline
Joined: 4th Apr 2004
Location:
Posted: 29th Sep 2009 09:39
technically it could be faster because that is pretty much a direct assembly language translation(shr or shl). but today's compilers are so optimized, it really wont make a noticeable difference.


If at first you dont succeed, call it version 1.0.

Login to post a reply

Server time is: 2026-06-10 03:29:47
Your offset time is: 2026-06-10 03:29:47