DarwinBotsManual
Open the app EspañolES

pow

Raises the lower number to the power of the upper one: 2 10 pow gives 1024. The exponent is limited to ±10.

Facts

Word
pow
Family
Advanced
Integer stack
pops 2, pushes 1
What it does
Pops two numbers and pushes the one below raised to the power of the one on top, rounded. The exponent is clipped to ±10, base 0 gives 0 and the result stays at ±2 billion.
Cost
Advanced command; debugint and debugbool are free
Runs
inside a gene: in the condition (cond) and in the body (start or else)

a b pow leaves a raised to the power b. 2 10 pow gives 1024, -2 3 pow gives −8 and 5 0 pow gives 1.

WordStack afterwards
22
102 10
pow1024

It has several limits worth knowing:

A practical use is calculating the value of a bit to use with the bitwise operators: 2 *50 pow is 1, 2, 4, 8… depending on what's in cell 50.

cond
start
  2 *50 pow 51 store
  *50 1 add 50 store
stop

In this bot cell 51 takes the values 1, 2, 4, 8… 1024, and stays there, because the exponent doesn't go past 10. The inverse operation is root, and the exponent needed to reach a number is given by logx.