Is there a quicker way to /4

Blitz3D Forums/Blitz3D Programming/Is there a quicker way to /4

Boiled Sweets(Posted 2003) [#1]
Is there a bit shift operator?

I have some like x/4 every time round my loop, is there a quicker way of achiving this?

i.e x>>2 + x>>2

Thanks


soja(Posted 2003) [#2]
Bit shift operators:
Shr, Shl

example:
x Shr 2
integer division by 4

But who knows -- maybe the compiler converts your x/4 to x Shr 2 during compile anyway...


eBusiness(Posted 2003) [#3]
Doubt, at least it makes a different exe file.


Beaker(Posted 2003) [#4]
If its a float you can multiply by 0.25. In my experience most of these optimisations are a waste of time and destroy readability.


FlameDuck(Posted 2003) [#5]
But who knows -- maybe the compiler converts your x/4 to x Shr 2 during compile anyway...
It does.
In my experience most of these optimisations are a waste of time and destroy readability.
They are. "Simple" maths are not the appropriate place to optimize anymore.


Rob(Posted 2003) [#6]
Yup. The place to optimise is the whole approach to the problem.