About numbers and rounding

Sometimes we want to display numbers as part of a sim. If you have a variable, like velocityOfCat for example, and want to display it using the function text(velocityOfCat) you might end up seeing a number with a lot of decimal places after it, (press play below to see a demo)

That many decimal places is obviously not too useful. So, we can use the function toFixed() to trim those unsightly numbers:

Other methods also exists for this. You can use the rounding functions of Javascript as well:

1
Math.round(velocityOfDog * 100) / 100 ;

will output something with 2 decimal places.