How do you format numbers in scientific notation?

Learn to display very large and very small numbers in JavaScript

Introduction

Scientific notation expresses numbers as a coefficient multiplied by a power of 10. For example, 123,000,000 becomes 1.23 × 10^8, and 0.000000456 becomes 4.56 × 10^-7. This format makes extremely large and extremely small numbers easier to read and compare.

Web applications that display scientific data, financial information, or technical measurements often need to format numbers this way. JavaScript provides built-in support for scientific notation through the Intl.NumberFormat API, which handles both formatting and localization.

This article shows you how to format numbers in scientific notation, control precision, understand locale-specific differences, and choose between scientific and engineering notation.

Format numbers in scientific notation

The Intl.NumberFormat constructor accepts a notation option that controls how numbers are displayed. Setting notation to "scientific" formats numbers in scientific notation.

const formatter = new Intl.NumberFormat('en-US', {
  notation: 'scientific'
});

console.log(formatter.format(987654321));
// Output: 9.877E8

The output 9.877E8 represents 9.877 × 10^8. The E separates the coefficient from the exponent.

Format very large numbers

Scientific notation simplifies the display of very large numbers by expressing them as a coefficient and exponent.

const formatter = new Intl.NumberFormat('en-US', {
  notation: 'scientific'
});

console.log(formatter.format(6.02214076e23));
// Output: 6.022E23

console.log(formatter.format(299792458));
// Output: 2.998E8

console.log(formatter.format(7800000000));
// Output: 7.8E9

The number 6.02214076e23 (Avogadro's constant) formats as 6.022E23, making it easier to read than 602,214,076,000,000,000,000,000.

Format very small numbers

Scientific notation also works for very small numbers, using negative exponents to represent values less than 1.

const formatter = new Intl.NumberFormat('en-US', {
  notation: 'scientific'
});

console.log(formatter.format(0.000000001));
// Output: 1E-9

console.log(formatter.format(0.00000000000000000016));
// Output: 1.6E-19

console.log(formatter.format(0.0000000456));
// Output: 4.56E-8

The number 0.00000000000000000016 (approximate charge of an electron in coulombs) formats as 1.6E-19, avoiding the need to count zeros.

Scientific notation formatting varies by locale

Different locales use different decimal separators in scientific notation. While the exponent separator remains E in most Latin-based locales, the decimal separator in the coefficient follows locale conventions.

const numberToFormat = 987654321;

// US English uses a period as the decimal separator
const usFormatter = new Intl.NumberFormat('en-US', {
  notation: 'scientific'
});
console.log(usFormatter.format(numberToFormat));
// Output: 9.877E8

// Portuguese uses a comma as the decimal separator
const ptFormatter = new Intl.NumberFormat('pt-PT', {
  notation: 'scientific'
});
console.log(ptFormatter.format(numberToFormat));
// Output: 9,877E8

// German also uses a comma as the decimal separator
const deFormatter = new Intl.NumberFormat('de-DE', {
  notation: 'scientific'
});
console.log(deFormatter.format(numberToFormat));
// Output: 9,877E8

The US English locale produces 9.877E8 with a period, while Portuguese and German locales produce 9,877E8 with a comma.

Control precision in scientific notation

The minimumSignificantDigits and maximumSignificantDigits options control how many digits appear in the formatted output. Significant digits include all digits in the coefficient, from the first non-zero digit to the last digit.

const formatter = new Intl.NumberFormat('en-US', {
  notation: 'scientific',
  minimumSignificantDigits: 3,
  maximumSignificantDigits: 3
});

console.log(formatter.format(123456789));
// Output: 1.23E8

console.log(formatter.format(0.00045678));
// Output: 4.57E-4

Setting both options to 3 limits the output to exactly three significant digits. Without these options, the formatter includes more digits from the original number.

You can also set different minimum and maximum values to allow variable precision.

const formatter = new Intl.NumberFormat('en-US', {
  notation: 'scientific',
  minimumSignificantDigits: 2,
  maximumSignificantDigits: 5
});

console.log(formatter.format(123456789));
// Output: 1.2346E8

console.log(formatter.format(100000000));
// Output: 1.0E8

This configuration allows between 2 and 5 significant digits, depending on the input number.

Format numbers in engineering notation

Engineering notation is a variant of scientific notation where the exponent is always a multiple of 3. This aligns with SI metric prefixes like kilo (10^3), mega (10^6), and giga (10^9).

const formatter = new Intl.NumberFormat('en-US', {
  notation: 'engineering'
});

console.log(formatter.format(987654321));
// Output: 987.654E6

console.log(formatter.format(0.000000456));
// Output: 456E-9

The number 987,654,321 formats as 987.654E6 in engineering notation, compared to 9.877E8 in scientific notation. The exponent 6 is a multiple of 3.

Differences between scientific and engineering notation

The main difference between scientific and engineering notation is how they choose the exponent. Scientific notation uses any integer exponent, while engineering notation restricts exponents to multiples of 3.

const scientificFormatter = new Intl.NumberFormat('en-US', {
  notation: 'scientific'
});

const engineeringFormatter = new Intl.NumberFormat('en-US', {
  notation: 'engineering'
});

const testNumbers = [105900, 1234567, 0.00045];

testNumbers.forEach(num => {
  console.log(`Number: ${num}`);
  console.log(`Scientific: ${scientificFormatter.format(num)}`);
  console.log(`Engineering: ${engineeringFormatter.format(num)}`);
  console.log('---');
});

// Output:
// Number: 105900
// Scientific: 1.059E5
// Engineering: 105.9E3
// ---
// Number: 1234567
// Scientific: 1.235E6
// Engineering: 1.235E6
// ---
// Number: 0.00045
// Scientific: 4.5E-4
// Engineering: 450E-6
// ---

For 105,900, scientific notation produces 1.059E5 while engineering notation produces 105.9E3. When the scientific notation already uses a multiple of 3 (as with 1,234,567 producing 1.235E6), both notations produce the same result.

Use cases for scientific and engineering notation

Scientific notation works well for applications that display data where readability and consistency matter more than alignment with metric prefixes.

Use scientific notation for:

  • Scientific calculators and computation tools
  • Astronomy applications (distances, masses, luminosities)
  • Chemistry applications (molecular masses, concentrations)
  • Physics simulations (particle masses, electromagnetic values)

Engineering notation works well for applications where users think in terms of metric prefixes or need to communicate values verbally.

Use engineering notation for:

  • Electronics applications (resistances in kilohms, capacitances in picofarads)
  • Electrical engineering tools (voltages, currents, powers)
  • Telecommunications systems (frequencies in megahertz, data rates in gigabits)
  • Mechanical engineering (forces in kilonewtons, torques in newton-meters)

The choice depends on your users and domain. Scientific notation provides consistent formatting across all numbers, while engineering notation aligns with how engineers communicate measurements.