Well - that's a pretty obvious answer, although clearly better than anything that I could come up with. I thought that 1000 operations might not be enough, so I tried one million. Here is the code ...
Sub testbed
Dim i, m, n As Int
Dim start, stop, duration As Long
n = 0xFFFFFF
start = DateTime.Now
For i = 0 To 999999
m = Bit.ShiftRight(n, 8)
Next
stop = DateTime.Now
duration = stop - start
Log("Time = " & duration)
start = DateTime.Now
For i = 0 To 999999
m = n / 256
Next
stop = DateTime.Now
duration = stop - start
Log("Time = " & duration)
End Sub
I ran it first on my desktop PC with B4J. Here is the result from the log ...
This was a bit unexpected - it suggests that the bit shifting route takes
longer than division. So then I ran it in Android (two-year old Google Pixel; Android 10) and got this result ...
I have been poring over this to see where I might have gone wrong, but if I have I cannot see where it is. So what is happenning?