round
fn round(float x) -> float Import
Source: use num::{round}; src/num.hy Rounds x to the nearest whole number; halves round away from zero.
Parameters#
| Name | Type |
|---|---|
x | float |
Returns#
float
Examples#
use num::{round};
use tests::assert;
assert!(round(2.5) == 3.0);
assert!(round(-2.5) == -3.0);
assert!(round(2.4) == 2.0);
See also#
abs: Returns the absolute value ofx.min: Returns the smaller ofaandb(awhen they are equal).max: Returns the larger ofaandb(awhen they are equal).clamp: Returnsxlimited to the rangelo..=hi.signum: Returns-1,0or1by the sign ofx.gcd: Returns the greatest common divisor ofaandb, which should be non-negative.lcm: Returns the least common multiple ofaandb, which should be non-negative;0when either is0.trunc: Removes the fractional part ofx, rounding toward zero.