Shift right without Bitwise

I’m porting this C# code:

i = 0x5f3759df - (i>> 1);

It essentially shifts a 64-bit Double one place to the right. How do I achieve this without using the Bitwise module? It has to run on iOS. I know I’ve seen related code on the forum before but I can’t find.

Could someone who gets binary math help me out please?


Turns out if I finish my coffee - I can can figure it out myself!

Public Function ShiftRight(i As Integer, places As Integer) as Integer Return i / (2 ^ places) End Function

Use \ instead for integer division.

Will do. Out of curiosity, is that for performance reasons since both i and places are already Integers?

Yes. Without knowing for sure, I suspect / will transform both to doubles first, then back to integer whereas the compiler will convert n \\ (2^places) to “shift right”.