floor

 

floor is a mathematics primitive that reports the closest integer below a given number. In other words, it rounds the number down. For example, floor 5.2 would report 5, and floor -4.8 would report -5.

In the model example below, each turtle has a my-money variable that increases or decreases a little bit at each tick. We use the floor primitive to round up a turtle's my-money variable because we want to present a label under each turtle showing their current money. If we do not round this variable either up or down, their labels would show many floating point numbers such as 1.822882372836, which would be visually unpleasant. We also use the floor primitive in setting each turtle's ycor parameter so that the turtles move only when the rounded-up version of their my-money variable changes. If they make or lose just a little bit of money, they remain stationary. Lastly, we use the floor, and its opposite ceiling, for two of our three monitors in the interface.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

Once you mastered the floor primitive, don't stop there. Check out the resources below to improve your NetLogo skills.

 
Published NetLogo models that use the floor primitive:
 
 
Similar primitives:
ceiling

Rounds a number up to the nearest integer.

Read more
round

Reports the integer that is nearest to a specified value.

Read more
mod

Performs the modulo operation; reports the remainder from the division of the first number by the second number.

Read more
count

Counts the number of agents in an agentset.

Read more
 
Learn another primitive: