View Single Post
Old Apr 27th, 2008, 2:31 PM   #6
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 766
Rep Power: 3 Jimbo is on a distinguished road
Re: Bitwise Operators...

Quote:
Originally Posted by Sane View Post
It's generally not used to do math, because the fact is the difference in speed is pretty much negligible.

...

The behaviour of each program is identical, except the first shifts and the second multiplies. They both do a billion shifts or a billion multiplications in the same amount of time.

This is because they are both constant time operations, and most modern compilers will do optimizations under the hood that make these differences negligible.
Source? I thought (at least in MIPS, we didn't cover x86 specifics at my school) that multiplication and division are not constant time operations, and required multiple assembly instructions to perform the operation and fetch the results.
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote