A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-number-toexponential-method/ below:

JavaScript Number toExponential() Method - GeeksforGeeks

JavaScript Number toExponential() Method

Last Updated : 22 May, 2023

JavaScript Number toExponential() method is used to convert a number to its exponential form. It returns a string representing the Number object in exponential notation. The toExponential() method is used with a number as shown in the above syntax using the ‘.’ operator. This method will convert a number to its exponential form.

Syntax:

number.toExponential(value)

Parameters: This method accepts a single parameter value. 

Return Value: The toExponential() method in JavaScript returns a string representing the given number in exponential notation with one digit before the decimal point.

Below is an example of the Number toExponential() Method:

Example 1: 

JavaScript
let num = 212.13456;
console.log(num.toExponential(4));        

Output:

Output :2.1213e+2

Example 2: Passing a number as an argument in the toExponential() method. If a number is passed as an argument to the toExponential() method then it represents the number of digits after the decimal point. 

JavaScript
let num = 2.13456;
console.log(num.toExponential(2));        

Output:

2.13e+0

Example 3: Passing no parameter in the toExponential() method. The below program illustrates this.

JavaScript
let num = 2.13456;
console.log(num.toExponential());        

Output:

2.13456e+0

Example 4: Passing a value that has more than 1 digit before the decimal point in the toExponential() method. The below program illustrates this:.

JavaScript
let num=212.13456;
console.log(num.toExponential());        

Output:

2.1213456e+2

Example 5: Passing zero as a parameter in the toExponential() method. The below program illustrates this.

JavaScript
let num = 212.13456;
console.log(num.toExponential(0));        

Output:

Output :2e+2

Exceptions:

Supported Browsers:

We have a complete list of JavaScript Number constructor, properties, and methods list, to know more about the numbers please go through that article.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4