Skip to contents

Element-wise truncation (round toward zero). You can also use trunc().

Usage

nv_trunc(x)

# S3 method for class 'AnvlArray'
trunc(x, ...)

Arguments

x

(arrayish)
One input. Can be any numeric data type: a float is rounded and keeps its own, and an integer one is already whole and is returned unchanged. An R value materializes at its default data type and is treated in the same way.

...

Further arguments of nv_trunc().

Value

(arrayish)
Has the input's shape and data type.

Examples

# the input's data type carries through
x <- nv_array(c(1.2, 2.7, -1.5))
trunc(x)
#> AnvlArray
#>   1
#>   2
#>  -1
#> [ CPUf32{3} ] 
trunc(nv_array(1:3)) # an integer array is already whole
#> AnvlArray
#>  1
#>  2
#>  3
#> [ CPUi32{3} ]