For instance:
a=a<<4;equals
a*=16; But multiplying by 100 (and for many other numbers) is also possible:
a*=100; equals
a= a*64 + a*32 + a*4; equals
a=(a<<6)+(a<<5)+(a<<2); Some compilers might optimise this by themselves.
Finally, when dealing with floats, you can also do fast multiplications by 2,4,5,6 (or by 10,100,1000 depending on the internal representation of the floats) simply by increasing/decreasing the exponent.
Author : Jean-François Geyelin
0 nhận xét:
Post a Comment