Skip to main content

round

Function round 

pub fn round(x: &Variant) -> Variant
Expand description

Rounds x to the nearest whole number, with halfway cases rounded away from 0. Supported types: int, float, Vector2, Vector2i, Vector3, Vector3i, Vector4, Vector4i.

round(2.4) # Returns 2
round(2.5) # Returns 3
round(2.6) # Returns 3

See also [method floor], [method ceil], and [method snapped].

Note: For better type safety, use [method roundf], [method roundi], round, round, or round.