floorstore
Puts a floor under a cell: if what it holds is smaller than the number, it raises it to that number.
Facts
- Word
floorstore- Family
- Writing to memory
- Integer stack
- pops 2, pushes 0
- What it does
- Pops an address and a value, and leaves the larger of the two in the cell: it is a floor. With address 0 the value is lost.
- Cost
- Store divided by the divisor of each one, only if it writes
- Cost divisor
- ÷ 5
- Runs
- in the body of a gene (start or else), and only if the top of the boolean stack is true or the stack is empty
- Marks ties
- yes
v d floorstore leaves in cell d the larger of what it held and v. If the cell is already above v, it does not change; if it is below, it ends up at v. It is a floor, like floor but applied directly to memory.
| Word | Stack after |
|---|---|
0 | 0 |
50 | 0 50 |
floorstore | (empty); cell 50 holds at least 0 |
The most common use is keeping a countdown from going negative:
' goes down by 7 from 30, without going below 0
cond
*.robage 0 =
start
30 50 store
stop
start
7 50 substore
0 50 floorstore
stopThe cell goes through 23, 16, 9, 2 and then stays at 0: substore takes it to −5 and floorstore raises it to 0 in the same cycle.
The name is a little confusing: “floor” sounds like rounding down, but here it means floor and it keeps the larger. The ceiling is ceilstore.
With address 0 the value is popped from the stack and lost. Like store, it notifies the tie system if you write to .tieang1 or .tielen1.