signi function

Rounding to Significant Digits

Rounding to Significant Digits

Rounds to significant digits similarly to signif.

signi(x, digits = 6)

Arguments

  • x: numeric vector to be rounded.
  • digits: number of significant digits required.

Returns

numeric vector close to x, i.e. by at least digits

significant digits.

Author(s)

Martin Maechler, in prehistoric times (i.e. before 1990).

Note

This is really just round(x, digits - trunc(log10(abs(x)))) and hence mainly of didactical use. Rather use signif() otherwise.

See Also

signif, round.

Examples

(x1 <- seq(-2, 4, by = 0.5)) identical(x1, signi(x1))# since 0.5 is exact in binary arithmetic (x2 <- pi - 3 + c(-5,-1,0, .1, .2, 1, 10,100)) signi(x2, 3)
  • Maintainer: Martin Maechler
  • License: GPL (>= 2)
  • Last published: 2024-11-05