This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Name

round()

Examples
float x = 9.2;  
int rx = round(x);  // Sets 'rx' to 9

float y = 9.5;
int ry = round(y);  // Sets 'ry' to 10

float z = 9.9;
int rz = round(z);  // Sets 'rz' to 10

Description Calculates the integer closest to the n parameter. For example, round(133.8) returns the value 134.
Syntax
round(n)
Parameters
n float: number to round
Returnsint
Relatedfloor()
ceil()
Updated on January 1, 2021 03:38:06am EST