round1.0

round number

Reports the integer nearest to number.

If the decimal portion of number is exactly .5, the number is rounded in the positive direction.

Note that rounding in the positive direction is not always how rounding is done in other software programs. (In particular, it does not match the behavior of StarLogoT, which always rounded numbers ending in 0.5 to the nearest even integer.) The rationale for this behavior is that it matches how turtle coordinates relate to patch coordinates in NetLogo. For example, if a turtle's xcor is -4.5, then it is on the boundary between a patch whose pxcor is -4 and a patch whose pxcor is -5, but the turtle must be considered to be in one patch or the other, so the turtle is considered to be in the patch whose pxcor is -4, because we round towards the positive numbers.

show round 4.2
=> 4
show round 4.5
=> 5
show round -4.5
=> -4

See also precision, ceiling, floor.

Take me to the full NetLogo Dictionary