Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Determine the number of significant digits in a number
ResourceFunction["SignificantDigits"][x] gives the number of significant digits in x. | |
ResourceFunction["SignificantDigits"][{x1,x2,…}] gives the list of results for each xi. |
Find the number of significant digits in a Real number:
In[1]:= |
Out[1]= |
Find the number of significant digits in a String representing a number:
In[2]:= |
Out[2]= |
Find the number of significant digits in an Integer number:
In[3]:= |
Out[3]= |
Find the number of significant digits in an exact Real number represented as a Rational number:
In[4]:= |
Out[4]= |
Determine the number of significant digits for a List of values:
In[5]:= |
Out[5]= |
Accuracy and Precision information in arbitrary-precision numbers is obeyed:
In[6]:= |
Out[6]= |
AccountingForm is supported:
In[7]:= |
Out[7]= |
DecimalForm and PercentForm are supported:
In[8]:= |
Out[8]= |
FortranForm and CForm are supported:
In[9]:= |
Out[9]= |
ISO expanded uncertainty is supported:
In[10]:= |
Out[10]= |
ScientificForm is supported:
In[11]:= |
Out[11]= |
Quantity, QuantityArray and MixedMagnitude values with units are supported:
In[14]:= |
Out[14]= |
In[15]:= |
Out[15]= |
In[16]:= |
Out[16]= |
The number of leading zeros, significant digits and trailing zeros before and after the decimal can be returned as an Association:
In[17]:= |
Out[17]= |
Leading zeros in a String of digits can be trimmed before processing:
In[19]:= |
Out[19]= |
In[20]:= |
Out[20]= |
Trailing zeros in Integer numbers can be treated as significant:
In[21]:= |
Out[21]= |
In[22]:= |
Out[22]= |
Do significant digit-compliant subtraction:
In[23]:= |
Out[23]= |
In[24]:= |
In[25]:= |
Out[25]= |
Trailing zeros in Integer numbers are always insignificant by default:
In[26]:= |
Out[26]= |
Enabling exact numbers also enables "UseTrailingZeros":
In[27]:= |
Out[27]= |
Whitespace and commas in String values are ignored:
In[28]:= |
Out[28]= |
String values without numbers in supported formats fail:
In[29]:= |
Out[29]= |
SignificantDigits output for Integer numbers is related to IntegerLength and IntegerExponent results:
In[30]:= |
Out[31]= |
SignificantDigits output for arbitrary-precision numbers is related to Precision and Accuracy results:
In[32]:= |
Out[32]= |
In[33]:= |
Out[33]= |
Around and VectorAround may produce unexpected results:
In[34]:= |
Out[34]= |
MachinePrecision numbers may produce unexpected results after computations:
In[35]:= |
Out[35]= |
In[36]:= |
Out[36]= |
In[37]:= |
Out[37]= |
Scientific notation containing a decimal implies a Real number and may produce unexpected results:
In[38]:= |
Out[38]= |
Trailing zeros in Real numbers are dropped unless specified using SetPrecision or SetAccuracy:
In[39]:= |
Out[39]= |
"UseTrailingZeros" is required to process an Integer number containing trailing zeros and a truncating Precision:
In[40]:= |
Out[40]= |
In[41]:= |
Out[41]= |
Compute a significant digit-compliant molecular mass from an element tally:
In[42]:= |
In[43]:= |
Out[43]= |
This work is licensed under a Creative Commons Attribution 4.0 International License