Testing latest pari + WASM + node.js... and it works?! Wow.
License: GPL3
ubuntu2004
Function: precision
Section: conversions
C-Name: precision00
Prototype: GDG
Help: precision(x,{n}): if n is present, return x at precision n. If n is
omitted, return real precision of object x.
Doc: the function behaves differently according to whether $n$ is
present or not. If $n$ is missing, the function returns
the floating point precision in decimal digits of the PARI object $x$. If $x$
has no floating point component, the function returns \kbd{+oo}.
\bprog
? precision(exp(1e-100))
%1 = 154 \\ 154 significant decimal digits
? precision(2 + x)
%2 = +oo \\ exact object
? precision(0.5 + O(x))
%3 = 38 \\ floating point accuracy, NOT series precision
? precision( [ exp(1e-100), 0.5 ] )
%4 = 38 \\ minimal accuracy among components
@eprog\noindent Using \kbd{getlocalprec()} allows to retrieve
the working precision (as modified by possible \kbd{localprec}
statements).
If $n$ is present, the function creates a new object equal to $x$ with a new
floating point precision $n$: $n$ is the number of desired significant
\emph{decimal} digits. If $n$ is smaller than the precision of a \typ{REAL}
component of $x$, it is truncated, otherwise it is extended with zeros.
For non-floating-point types, no change.
Variant: Also available are \fun{GEN}{gprec}{GEN x, long n} and
\fun{long}{precision}{GEN x}. In both, the accuracy is expressed in
\emph{words} (32-bit or 64-bit depending on the architecture).