Pages

Saturday 16 June 2012

Four Dealings with the Number in NetLogo: "round","precision", "ceiling", "floor" in NetLogo


  • round

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.
show round 4.2
=> 4
show round 4.5
=> 5
show round -4.5
=> -4


  • precision

precision number places

Reports number rounded to places decimal places.
If places is negative, the rounding takes place to the left of the decimal point.
show precision 1.23456789 3
=> 1.235
show precision 3834 -3
=> 4000
  
  • ceiling

ceiling number

Reports the smallest integer greater than or equal to number.
show ceiling 4.5
=> 5
show ceiling -4.5
=> -4
  
  • floor

floor number

Reports the largest integer less than or equal to number.
show floor 4.5
=> 4
show floor -4.5
=> -5

No comments:

Post a Comment