Skip to content

Accuracy

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

Accuracy[x]
    Returns the number of digits of accuracy in x — equal to
    Precision[x] − Log10[Abs[x]]. Exact numbers (including exact 0)
    return Infinity. Inexact zeros are finite: machine 0. returns
    ≈ 323.607; MPFR 0 of precision p returns p digits.

Examples

No verified examples yet for this function.

Implementation notes

builtin_accuracy (src/precision.c) delegates to accuracy_of, which returns the number of correct digits to the right of the decimal point. Exact quantities (integers, bigints, exact rationals, strings, symbols, exact zero) return Infinity. For inexact reals it returns MachinePrecisionDigits - log10|x|; for EXPR_MPFR it uses the value's actual precision (mpfr_get_prec / log2(10)) minus log10|x| (inexact zero gets the precision in digits directly). Complex[re, im] and general function arguments recurse and take the minimum (precision_min) over components/arguments. Accuracy is ATTR_LISTABLE, so it threads over lists.

Attributes: Listable, Protected.

Implementation status

Stable — documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

References

Notes & additional examples

Worked examples

In[1]:= Accuracy[1.5]
Out[1]= 15.7785

In[2]:= Accuracy[5]
Out[2]= Infinity

In[3]:= Accuracy[N[Pi, 30]]
Out[3]= 29.6058
In[1]:= Accuracy[N[10^20, 30]]
Out[1]= 10.103

In[2]:= Accuracy[N[1/10^20, 30]]
Out[2]= 50.103
In[1]:= Accuracy[0.]
Out[1]= 323.607

Notes

Accuracy gives the number of digits to the right of the decimal point, i.e. the digit count relative to the absolute (not relative) magnitude, satisfying Accuracy[x] == Precision[x] - Log10[Abs[x]]. Exact numbers have Infinity accuracy. For a fixed precision of 30 digits, the same Pi-style relative precision yields very different accuracies as magnitude changes: N[10^20, 30] has only 10.1 digits past the point, while N[1/10^20, 30] has 50.1. Inexact zero is the special case — machine 0. returns the finite value 323.607 rather than Infinity.