DarwinBotsManual
Open the app EspañolES

floor

Sets a floor: of the top two numbers on the stack it leaves the larger, so x 0 floor never goes below 0.

Facts

Word
floor
Family
Advanced
Integer stack
pops 2, pushes 1
What it does
Pops two numbers and pushes the larger one: it sets a floor and does not round, whatever the name suggests.
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 floor leaves the larger of the two: x if it is above the limit, and the limit if not. As with ceil, the name (floor) describes the limit and not the operation: the result is the maximum. -50 0 floor gives 0 and 80 0 floor gives 80.

The classic use is avoiding negatives. Saber, by abyaly, writes to .dn the difference between 180 and its speed (.velscalar), but never a negative number: if it is already going faster than 180, it writes 0.

cond
start
  180 *.velscalar sub 0 floor .dn store
stop

With x 5 floor 50 ceil, or in the other order, the value ends up fenced between 5 and 50. To write the maximum straight into a cell there is floorstore.