Skip to main content

toExponential() Method – How to Convert Numbers to Exponential Notations

toExponential() converts a number to its exponential equivalent (Scientific Notation).

In other words, whenever you use toExponential() on a number, the method does the following:

  • It places a decimal point after the first digit of the specified number.
  • It uses an exponential notation to express how many places it moved the decimal point.

For instance, consider the following number:

703.59

7.0359e+2 is the exponential equivalent of the number above because we moved the decimal point twice from its initial position to its final place.

Illustration of a number's
exponent

An e+2 exponential notation means the number's decimal point moved two places to the left.

note
  • The exponential notation (e+2) in 7.0359e+2 means exponent 10 to the power 2 (102). In other words, 7.0359e+2 is equivalent to 7.0359 x 102.
  • toExponential() is sometimes written as Number.prototype.toExponential() because it is a method of the Number object's prototype property.

Syntax of the toExponential() Method

toExponential() accepts only one optional argument. Here is the syntax:

number.toExponential(totalFractionDigits);

The totalFractionDigits argument specifies the number of digits browsers should show after the decimal point. If omitted, browsers will use as many digits as necessary to represent the number.

note
  • toExponential() returns a string value.
  • toExponential() does not change the original number.
  • Browsers round the returned value if necessary.

Examples of the toExponential() Method

Below are examples of the toExponential() method.

Convert 703.59 to an exponential notation

const number = 703.59;

number.toExponential();

// The invocation above will return: 7.0359e+2

Try Editing It

Convert 7.0359 to an exponential notation

const number = 7.0359;

number.toExponential();

// The invocation above will return: 7.0359e+0

Try Editing It

Convert 0.70359 to an exponential notation

const number = 0.70359;

number.toExponential();

// The invocation above will return: 7.0359e-1

Try Editing It

Convert 0.000070359 to an exponential notation

const number = 0.000070359;

number.toExponential();

// The invocation above will return: 7.0359e-5

Try Editing It

Convert 703.59 to an exponential notation with no decimal digits

const number = 703.59;

number.toExponential(0);

// The invocation above will return: 7e+2

Try Editing It

Convert 703.59 to an exponential notation with only one decimal digit

const number = 703.59;

number.toExponential(1);

// The invocation above will return: 7.0e+2

Try Editing It

Convert 703.59 to an exponential notation with three decimal digits

const number = 703.59;

number.toExponential(3);

// The invocation above will return: 7.036e+2

Try Editing It

Convert 703.59 to an exponential notation with seven decimal digits

const number = 703.59;

number.toExponential(7);

// The invocation above will return: 7.0359000e+2

Try Editing It

Overview

This article discussed what toExponential() is. We also used examples to see how it works.

Your support matters: Buy me a coffee to support CodeSweetly's mission of simplifying coding concepts.

Join CodeSweetly Newsletter