How to format numbers in engineering notation
Use engineering notation to display numbers with exponents that align with SI unit prefixes
Introduction
Engineering notation is a way of writing numbers using powers of 10 where the exponent is always a multiple of 3. Instead of displaying 123,000,000 as 1.23×10⁸, engineering notation displays it as 123×10⁶. This alignment with multiples of 3 matches the International System of Units (SI) prefixes like kilo (10³), mega (10⁶), and giga (10⁹).
This notation appears frequently in engineering, electronics, and scientific contexts where measurements use SI prefixes. A capacitor rated at 4.7×10⁻⁶ farads becomes 4.7 microfarads. A frequency of 2.4×10⁹ hertz becomes 2.4 gigahertz. Engineering notation makes these conversions natural because the exponent directly corresponds to the SI prefix.
JavaScript provides built-in support for engineering notation through the Intl.NumberFormat API. This API handles the conversion automatically and adapts the formatting to different languages and regions.
What engineering notation is
Engineering notation expresses numbers as a coefficient multiplied by a power of 10, where the exponent is always divisible by 3. The number 987,654,321 becomes 987.654×10⁶ in engineering notation, written as 987.654E6 in JavaScript output.
The coefficient appears as a number between 1 and 999.999, followed by E and the exponent. The E stands for exponent and indicates multiplication by 10 raised to that power. The value 987.654E6 means 987.654 × 10⁶, which equals 987,654,000.
This format differs from standard decimal notation, which writes all digits with separators like 987,654,321. It also differs from compact notation, which uses letters like K, M, and B to represent magnitudes. Engineering notation explicitly shows the power of 10 using exponent notation.
Why engineering notation uses multiples of three
The restriction to multiples of 3 exists because SI unit prefixes increase or decrease by factors of 1000. Each step up the prefix scale multiplies by 10³, and each step down divides by 10³.
Consider the SI prefixes for powers of 10:
- 10³ = kilo (k)
- 10⁶ = mega (M)
- 10⁹ = giga (G)
- 10¹² = tera (T)
- 10⁻³ = milli (m)
- 10⁻⁶ = micro (μ)
- 10⁻⁹ = nano (n)
- 10⁻¹² = pico (p)
When a number uses engineering notation with an exponent of 6, you know it corresponds to the mega prefix. When the exponent is -9, you know it corresponds to the nano prefix. This direct correspondence makes engineering notation practical for technical fields where SI units dominate.
Without this restriction, you would need to perform mental arithmetic to convert between notation and SI prefixes. With the restriction, the conversion is immediate.
How engineering notation differs from scientific notation
Scientific notation also expresses numbers using powers of 10, but it uses the smallest possible exponent. The number 987,654,321 becomes 9.87654321×10⁸ in scientific notation, written as 9.87654321E8.
Scientific notation always places exactly one non-zero digit before the decimal point. Engineering notation allows up to three digits before the decimal point to ensure the exponent is divisible by 3.
const scientificFormatter = new Intl.NumberFormat("en-US", {
notation: "scientific"
});
console.log(scientificFormatter.format(987654321));
// Output: "9.877E8"
const engineeringFormatter = new Intl.NumberFormat("en-US", {
notation: "engineering"
});
console.log(engineeringFormatter.format(987654321));
// Output: "987.654E6"
The scientific formatter produces 9.877E8, placing one digit before the decimal. The engineering formatter produces 987.654E6, placing three digits before the decimal to achieve an exponent of 6 instead of 8.
Both notations represent the same value, but engineering notation prioritizes alignment with SI prefixes over minimizing the exponent.
Using engineering notation in JavaScript
The notation option in Intl.NumberFormat controls how numbers are represented. Setting it to "engineering" enables engineering notation.
const formatter = new Intl.NumberFormat("en-US", {
notation: "engineering"
});
console.log(formatter.format(1500));
// Output: "1.5E3"
console.log(formatter.format(1500000));
// Output: "1.5E6"
console.log(formatter.format(1500000000));
// Output: "1.5E9"
The formatter automatically chooses the appropriate exponent based on the number's magnitude. The exponent is always a multiple of 3, ensuring alignment with SI prefixes.
You do not need to calculate the correct exponent or coefficient. The Intl API handles these calculations based on the number's value.
How engineering notation formats different magnitudes
Engineering notation applies at all scales, from very small to very large numbers. Understanding how different magnitudes map to exponents helps you predict the output.
const formatter = new Intl.NumberFormat("en-US", {
notation: "engineering"
});
console.log(formatter.format(0.0015));
// Output: "1.5E-3"
console.log(formatter.format(0.0000015));
// Output: "1.5E-6"
console.log(formatter.format(1.5));
// Output: "1.5E0"
console.log(formatter.format(1500));
// Output: "1.5E3"
console.log(formatter.format(1500000));
// Output: "1.5E6"
console.log(formatter.format(1500000000));
// Output: "1.5E9"
console.log(formatter.format(1500000000000));
// Output: "1.5E12"
Small numbers below 1 use negative exponents. The number 0.0015 becomes 1.5E-3, corresponding to the milli prefix. The number 0.0000015 becomes 1.5E-6, corresponding to the micro prefix.
Numbers around 1 use an exponent of 0. The number 1.5 becomes 1.5E0, which equals 1.5 × 10⁰ = 1.5 × 1 = 1.5.
Large numbers use positive exponents. The number 1500 becomes 1.5E3, corresponding to the kilo prefix. The pattern continues for mega, giga, and tera.
Controlling decimal places in engineering notation
By default, the formatter includes several decimal places in the coefficient. You can control precision using the minimumFractionDigits and maximumFractionDigits options.
const defaultFormatter = new Intl.NumberFormat("en-US", {
notation: "engineering"
});
console.log(defaultFormatter.format(1234567));
// Output: "1.235E6"
const noDecimalsFormatter = new Intl.NumberFormat("en-US", {
notation: "engineering",
maximumFractionDigits: 0
});
console.log(noDecimalsFormatter.format(1234567));
// Output: "1E6"
const twoDecimalsFormatter = new Intl.NumberFormat("en-US", {
notation: "engineering",
maximumFractionDigits: 2
});
console.log(twoDecimalsFormatter.format(1234567));
// Output: "1.23E6"
The maximumFractionDigits option limits how many digits appear after the decimal point in the coefficient. Setting it to 0 removes all decimal places, showing only the integer portion of the coefficient.
You can also enforce a minimum number of decimal places to maintain consistent formatting across multiple numbers.
const formatter = new Intl.NumberFormat("en-US", {
notation: "engineering",
minimumFractionDigits: 2,
maximumFractionDigits: 2
});
console.log(formatter.format(1000));
// Output: "1.00E3"
console.log(formatter.format(1500));
// Output: "1.50E3"
console.log(formatter.format(1234567));
// Output: "1.23E6"
This ensures all numbers show exactly two decimal places, which helps maintain visual consistency in tables and reports.
How engineering notation works across locales
Engineering notation adapts to different locale conventions for decimal separators. The exponent format remains consistent, but the coefficient formatting changes based on the locale.
const enFormatter = new Intl.NumberFormat("en-US", {
notation: "engineering"
});
console.log(enFormatter.format(1234567));
// Output: "1.235E6"
const deFormatter = new Intl.NumberFormat("de-DE", {
notation: "engineering"
});
console.log(deFormatter.format(1234567));
// Output: "1,235E6"
const frFormatter = new Intl.NumberFormat("fr-FR", {
notation: "engineering"
});
console.log(frFormatter.format(1234567));
// Output: "1,235E6"
English uses a period as the decimal separator in the coefficient. German and French use a comma as the decimal separator. The E and the exponent remain the same across all locales.
This localization applies only to the coefficient portion. The exponent notation using E and the exponent value follows international scientific conventions and does not change between locales.
Combining engineering notation with other formatting options
Engineering notation works with other number formatting options. You can control rounding, significant digits, and sign display while using engineering notation.
const formatter = new Intl.NumberFormat("en-US", {
notation: "engineering",
signDisplay: "always"
});
console.log(formatter.format(1500000));
// Output: "+1.5E6"
console.log(formatter.format(-1500000));
// Output: "-1.5E6"
The signDisplay option controls whether positive numbers show a plus sign. Setting it to "always" displays the sign for both positive and negative values.
You can also control significant digits instead of decimal places.
const formatter = new Intl.NumberFormat("en-US", {
notation: "engineering",
minimumSignificantDigits: 4,
maximumSignificantDigits: 4
});
console.log(formatter.format(1234567));
// Output: "1.235E6"
console.log(formatter.format(1567890));
// Output: "1.568E6"
The minimumSignificantDigits and maximumSignificantDigits options control the total number of meaningful digits in the coefficient, rather than just the decimal places.
When to use engineering notation
Engineering notation works best in technical contexts where measurements use SI unit prefixes. Electronics documentation, scientific papers, and engineering specifications commonly use this notation.
When documenting a circuit with a 4.7×10⁻⁶ farad capacitor, engineering notation displays the value as 4.7E-6. Engineers recognize this immediately as 4.7 microfarads. When displaying a 2.4×10⁹ hertz frequency, engineering notation shows 2.4E9, which engineers recognize as 2.4 gigahertz.
This notation is less suitable for general audiences who may not understand exponent notation. Social media counters, e-commerce prices, and consumer-facing dashboards should use standard notation or compact notation instead.
Do not use engineering notation when precision is critical and all digits matter. Financial calculations, legal documents, and audit trails require exact decimal representations. A bank balance should show $1,234.56, not 1.23456E3.
Consider your audience. Engineers, physicists, and technical professionals expect and understand engineering notation. General consumers find standard notation or compact notation easier to read.