DarwinBotsManual
Open the app EspañolES

mult

Multiplies the top two numbers of the integer stack; if the product goes over 2 billion, it stays at that cap.

Facts

Word
mult
Family
Basic
Integer stack
pops 2, pushes 1
What it does
Pops two numbers and pushes their product. If it goes past 2 billion, it stays at ±2 billion.
Cost
Basic command
Runs
inside a gene: in the condition (cond) and in the body (start or else)

a b mult leaves a · b. It's useful for scaling a read (*.eye5 2 mult), for building numbers bigger than the maximum literal (200 200 mult gives 40000) and, together with div, for proportional calculations.

WordStack afterwards
300300
300300 300
mult90000

Unlike add and sub, which wrap around, mult saturates: if the product goes over 2 billion (in either direction), it leaves exactly ±2000000000.

What you do have to keep in mind is the clipping when storing. The stack can hold the 90000, but a memory cell can't:

cond
start
  300 300 mult 50 store
  300 300 mult 300 div 51 store
stop

Cell 50 ends up at 26000 (the remainder of dividing 90000 by 32000) and cell 51 at 300, because the division shrank the number before storing it. See Numbers and addresses.