Math.round(value) Last updated: 09. Jan 2023

Rounds a number to the closest whole number.

Parameters

Name Type Description
value number Value to round.

Returns

A rounded number.

Example

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
// expected output: 1
#Math.round(0.9)# 

// expected output: 6 6 5
#Math.round(5.95)# #Math.round(5.5)# #Math.round(5.05)#

// expected output: -5 -5 -6
#Math.round(-5.05)# #Math.round(-5.5)# #Math.round(-5.95)#

Output

The #JS code above produces the output shown below:
// expected output: 1
1 

// expected output: 6 6 5
6 6 5

// expected output: -5 -5 -6
-5 -5 -6