Get the number of decimal places in a numeric vector
Arguments
- x
A numeric vector.
Value
A numeric vector with the same length as x, giving the number of decimal places for each element in x.
Examples
get_precision(1:5)
#> [1] 0 0 0 0 0
get_precision(c(1.2, 1.23, 1.234))
#> [1] 1 2 3
get_precision(c(1e-7, 1e16)) # tiny/huge numbers are handled too
#> [1] 7 0