DarwinBotsManual
Open the app EspañolES

-

A loose minus sign flips the sign of the top number: 5 - leaves −5. It doesn't subtract; for that there is sub.

Facts

Word
-
Family
Bitwise
Integer stack
pops 1, pushes 1
What it does
Flips the sign of the top: 5 becomes −5. It does not subtract; for subtraction use sub. With an empty stack it leaves 0.
Cost
Bitwise command
Runs
inside a gene: in the condition (cond) and in the body (start or else)

x - pops a number and pushes the same one with its sign flipped: 5 - gives −5 and -7 - gives 7. It is a single-operand operator, and that's why it's easy to mix up.

It's useful for inverting a read. This bot pushes forward for its first 5 cycles and then brakes by pushing, every cycle, as much as its forward velocity (.velup) but the other way around. In a few cycles it comes to a stop:

' accelerates for 5 cycles and then brakes
cond
  *.robage 5 <
start
  10 .up store
stop

cond
  *.robage 5 >=
start
  *.velup - .up store
stop

When the velocity is negative, - makes it positive and .up pushes forward: the same gene brakes in both directions.

To flip the sign of a memory cell, without going through the stack, there is negstore. With an empty stack, - leaves 0. Although it is in the bitwise family, it doesn't touch the bits.