return to homepage

Scripts: Javascript

Math.round

This maths function allows you to round decimal numbers up and down:

Also see how this can be applied to display random images...
...or generate random numbers

// To turn a decimal into integer use the following (e.g. 0.7453 or 1.23452...):
// Math.round(ranNum) to round it to the nearest integer (whole number)
// Math.floor(ranNum) to round down
// Math.ceil(ranNum) to round up