Documentation moved.
This entry is documented with its primary interface. Open the documentation →
Function
src/index.ts:1138nerdamer.significant
nerdamer.significant(x: ExpressionInput, digits: ExpressionInput): ExpressionRounds a number to the requested number of significant figures.
Unlike round(x, n), which counts decimal places, this operation
counts significant digits from the first nonzero digit. It changes the
numeric value rather than just its display format (unlike scientific).
Zero stays zero; complex values are rounded component by component.
Symbolic values remain unevaluated until they become numeric.
Parameters
| Name | Type | Description |
|---|---|---|
x | ExpressionInput | Number or expression to round. |
digits | ExpressionInput | Positive integer number of significant figures. |
Returns
Expression — The rounded value, or a symbolic significant(x, digits) call.
Examples
significant('1.23423534e-12', 3).text() // '0.00000000000123'
significant('12345', 3).text() // '12300'
significant('0.009876', 2).text() // '0.0099'