DarwinBotsManual
Open the app EspañolES

absstore

Strips the sign from what is in a cell: a negative becomes positive.

Facts

Word
absstore
Family
Writing to memory
Integer stack
pops 1, pushes 0
What it does
Pops an address and drops the sign of the cell: −77 becomes 77.
Cost
Store divided by the divisor of each one, only if it writes
Cost divisor
÷ 8
Runs
in the body of a gene (start or else), and only if the top of the boolean stack is true or the stack is empty
Marks ties
no

d absstore pops the address d and leaves in the cell the absolute value of what it held: −77 becomes 77, and a positive stays the same. It takes no value from the stack.

WordStack after
5050
absstore(empty); if cell 50 held −77, it now holds 77

It is handy for measuring a distance regardless of side:

' stores in 50 how far the energy is from 5000, above or below
cond
start
 *.nrg 5000 sub 50 store
 50 absstore
stop

With 3000 energy (.nrg) the cell ends up at 2000, just as with 7000. After that a single comparison, such as *50 500 <, is enough to tell whether the energy is close to 5000.

It is the same as *50 abs 50 store (see abs), with fewer words and at one eighth of the cost of a store. To flip the sign instead of removing it there is negstore.