DarwinBotsManual
Open the app EspañolES

ceil

Sets a ceiling: of the top two numbers on the stack it leaves the smaller, so x 100 ceil never goes above 100.

Facts

Word
ceil
Family
Advanced
Integer stack
pops 2, pushes 1
What it does
Pops two numbers and pushes the smaller one: it sets a ceiling and does not round, whatever the name suggests. Above 16,777,216 the comparison loses precision.
Cost
Advanced command; debugint and debugbool are free
Runs
inside a gene: in the condition (cond) and in the body (start or else)

x limit ceil leaves the smaller of the two: x if it is below the limit, and the limit if not. The name comes from that (ceiling), even though the result is the minimum, which confuses more than a few people. 7 100 ceil gives 7 and 700 100 ceil gives 100.

It is used to keep a computed value from going past a limit before storing it. This bot pushes forward with a tenth of its energy, but never with more than 30:

cond
start
  *.nrg 10 div 30 ceil .up store
stop

Combined with its counterpart, floor, it fences a value into a range: x 50 ceil 5 floor ends up between 5 and 50 (see the Saber example in Advanced).

A quirk that only shows with enormous numbers: ceil compares with less precision than floor, and above 16,777,216 the result can come out off by a few units (more the bigger the number is). With numbers the size of memory it never happens. To write the minimum straight into a cell there is ceilstore.