format01prec {DPQ} | R Documentation |
Format Numbers in [0,1] with "Precise" Result
Description
Format numbers in [0,1] with “precise” result,
notably using "1-.."
if needed.
Usage
format01prec(x, digits = getOption("digits"), width = digits + 2,
eps = 1e-06, ...,
FUN = function(x, ...) formatC(x, flag = "-", ...))
Arguments
x |
numbers in [0,1]; (still works if not) |
digits |
number of digits to use; is used as
|
width |
desired width (of strings in characters), is used as
|
eps |
small positive number: Use |
... |
optional further arguments passed to |
FUN |
a |
Value
a character
vector of the same length as x
.
Author(s)
Martin Maechler, 14 May 1997
See Also
Examples
## Show that format01prec() does reveal more precision :
cbind(format (1 - 2^-(16:24)),
format01prec(1 - 2^-(16:24)))
## a bit more variety
e <- c(2^seq(-24,0, by=2), 10^-(7:1))
ee <- sort(unique(c(e, 1-e)))
noquote(ff <- format01prec(ee))
data.frame(ee, format01prec = ff)
[Package DPQ version 0.5-8 Index]