round

Function round 

Source
pub fn round(arg: &Expression) -> Expression
Expand description

Round function (round to nearest integer)

§Mathematical Definition

round(x) rounds to nearest integer, with ties rounding away from zero

§Arguments

  • arg - Expression to round

§Returns

Rounded expression

§Examples

use mathhook_core::functions::elementary::rounding::round;
use mathhook_core::{expr, Expression};

assert_eq!(round(&Expression::float(3.4)), Expression::integer(3));
assert_eq!(round(&Expression::float(3.6)), Expression::integer(4));
assert_eq!(round(&Expression::float(3.5)), Expression::integer(4));