DarwinBotsManual
Open the app EspañolES

>>

Shifts the bits of the top number one place to the right, keeping the sign: it divides by 2 rounding down, so 7 >> leaves 3 and −5 >> leaves −3.

Facts

Word
>>
Family
Bitwise
Integer stack
pops 1, pushes 1
What it does
Shifts the bits of the top one place to the right, keeping the sign: it divides it by 2, rounding down. −1 >> stays at −1.
Cost
Bitwise command
Runs
inside a gene: in the condition (cond) and in the body (start or else)

x >> pops a number, shifts its bits one place to the right and pushes the result. The sign bit is preserved, so a negative stays negative. In practice it's dividing by 2 rounding down:

Stack beforeAfter >>With 2 div
844
734
522
-5-3-2
-1-10

Note that it isn't the same as div by 2. div rounds to the nearest integer, and on an exact tie to the even one; >> always goes down. With negatives the difference is more visible: -1 >> stays at −1 forever.

This bot keeps in cell 50 a quarter of its energy (.nrg), with two shifts in a row:

cond
start
  *.nrg >> >> 50 store
stop

With 3000 energy, the cell ends up at 750. In the first cycle of life it stores 0, because the senses haven't been published yet (see Execution and costs).

With an empty stack it leaves 0. The left shift is <<.