- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to force a number to display in exponential notation?
Use the toExponential() method to force a number to display in exponential notation, even if the number is in the range in which JavaScript normally uses standard notation.
The following is the parameter −
- fractionDigits - An integer specifying the number of digits after the decimal point. Defaults to as many digits as necessary to specify the number.
Example
You can try to run the following code to force a number to display in exponential function −
<html> <head> <title>Javascript Method toExponential()</title> </head> <body> <script> var num=77.1234; var val = num.toExponential(); document.write("num.toExponential() is : " + val ); document.write("<br />"); val = num.toExponential(4); document.write("num.toExponential(4) is : " + val ); document.write("<br />"); val = num.toExponential(2); document.write("num.toExponential(2) is : " + val); document.write("<br />"); val = 77.1234.toExponential(); document.write("77.1234.toExponential()is : " + val ); document.write("<br />"); val = 77.1234.toExponential(); document.write("77 .toExponential() is : " + val); </script> </body> </html>
Advertisements