Function reference · Math

scientific

Writes a number in scientific notation.

A second argument sets the significant digits, from 1 to 1e9 (10 by default). Only the display changes; the value stays exact for later calculations.

Notation

scientific(value[, significantDigits])

Write it in an expression: nerdamer('scientific(12345,3)'), or in the Playground.

nerdamer.scientific

nerdamer.scientific(value: ExpressionInput, significantDigits: ExpressionInput): Expression

A method on the default import. Arguments can be strings, as in Notation.

Parameters

value
Expression whose numeric values should use scientific notation.
significantDigits
Optional integer from 1 through 1e9. The coefficient retains exactly this many significant digits. Defaults to 10.

Examples

Three significant digits.

scientific(12345,3)
// → 1.23e4
Open in Playground

Trailing zeros are kept to show the precision.

scientific(1200,4)
// → 1.200e3
Open in Playground

A fraction.

scientific(1/8,4)
// → 1.250e-1
Open in Playground

A negative number, rounded.

scientific(-987654,4)
// → -9.877e5
Open in Playground

← Back to Function reference