Skip to contents

Rounds the elements of an array to the nearest integer.

Usage

prim_round(operand, method = "nearest_even")

Arguments

operand

(arrayish)
Arrayish value of data type floating-point.

method

(character(1))
Rounding method. "nearest_even" (default) rounds to the nearest even integer on a tie, "afz" rounds away from zero on a tie.

Value

arrayish
Has the same dtype and shape as operand. It is ambiguous if the input is ambiguous.

Implemented Rules

  • stablehlo

  • reverse

StableHLO

Lowers to stablehlo::hlo_round_nearest_even() or stablehlo::hlo_round_nearest_afz() depending on the method parameter.

See also

Examples

x <- nv_array(c(1.4, 2.5, 3.6))
prim_round(x)
#> AnvlArray
#>  1
#>  2
#>  4
#> [ CPUf32{3} ]