canalrun Well-Known Member Licensed User Longtime User Feb 13, 2019 #1 I'm converting a C program to B4R. In the C program I have: Code: Copy do { l >>= 1 } while (mr+l > nn) above "l >>= 1" is guaranteed to execute at least once. in B4R if I do: Code: Copy Do Until ((mr + l) <= nn) l = Bit.ShiftRight(l, 1) Loop Is this the same? Is the condition tested at the top or end of the loop? Is "l = Bit.ShiftRight(l, 1)" guaraneed to execute at least once. Or maybe in B4R if I do: Code: Copy Do While (True) l = Bit.ShiftRight(l, 1) if ((mr + l) <= nn) then exit Loop The documentation and "Beginners Manual" don't explicitly answer this. Thanks, Barry.
I'm converting a C program to B4R. In the C program I have: Code: Copy do { l >>= 1 } while (mr+l > nn) above "l >>= 1" is guaranteed to execute at least once. in B4R if I do: Code: Copy Do Until ((mr + l) <= nn) l = Bit.ShiftRight(l, 1) Loop Is this the same? Is the condition tested at the top or end of the loop? Is "l = Bit.ShiftRight(l, 1)" guaraneed to execute at least once. Or maybe in B4R if I do: Code: Copy Do While (True) l = Bit.ShiftRight(l, 1) if ((mr + l) <= nn) then exit Loop The documentation and "Beginners Manual" don't explicitly answer this. Thanks, Barry.
OliverA Expert Licensed User Longtime User Feb 13, 2019 #2 You’ll have to go the do while true route or Code: Copy l = Bit.ShiftRight(l, 1) Do Until ((mr + l) <= nn) l = Bit.ShiftRight(l, 1) Loop or a little closer to the original (when it comes to the condition) Code: Copy l = Bit.ShiftRight(l, 1) Do While (mr+l > nn) l = Bit.ShiftRight(l, 1) Loop Upvote 0
You’ll have to go the do while true route or Code: Copy l = Bit.ShiftRight(l, 1) Do Until ((mr + l) <= nn) l = Bit.ShiftRight(l, 1) Loop or a little closer to the original (when it comes to the condition) Code: Copy l = Bit.ShiftRight(l, 1) Do While (mr+l > nn) l = Bit.ShiftRight(l, 1) Loop