- Trending Categories
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 display numbers in scientific notation in Java?
To display number in scientific notation, create NumberFormat object first −
NumberFormat numFormat = newDecimalFormat();
Now, let’s say you need to format the minimum value of Integer −
int i = Integer.MIN_VALUE; System.out.println(i); numFormat = newDecimalFormat("0.######E0"); System.out.println(numFormat.format(i)); numFormat = newDecimalFormat("0.#####E0"); System.out.println(numFormat.format(i));
Above, we have used format() method of the NumberFormat class.
Example
import java.text.DecimalFormat; import java.text.NumberFormat; public class Demo { public static void main(String args[]) { NumberFormat numFormat = new DecimalFormat(); int i = Integer.MIN_VALUE; System.out.println(i); numFormat = new DecimalFormat("0.######E0"); System.out.println(numFormat.format(i)); numFormat = new DecimalFormat("0.#####E0"); System.out.println(numFormat.format(i)); double val = 0.37872; numFormat = new DecimalFormat("0.#####E0"); System.out.println(numFormat.format(val)); numFormat = new DecimalFormat("000000E0"); System.out.println(numFormat.format(val)); } }
Output
-2147483648 -2.147484E9 -2.14748E9 3.7872E-1 378720E-6
- Related Articles
- How to deactivate scientific notation of numbers in R?
- Prevent scientific notation in matplotlib.pyplot
- Express 5600000 in Scientific notation.
- How to Convert Scientific Notation to X10 Format in Excel?
- How to Convert Scientific Notation to Text or Number in Excel?
- How to change the font size of scientific notation in Matplotlib?
- How to repress scientific notation in factorplot Y-axis in Seaborn / Matplotlib?
- How to remove scientific notation form base R plot?
- How to find the mean of very small numbers in numeric form that are represented with scientific notation in R?
- How to remove scientific notation from a Matplotlib log-log plot?
- How to force a number to display in exponential notation?
- How to display xtable values in scientific form in R?
- Express the number of seconds in two years in scientific notation.>
- How to convert a String containing Scientific Notation to correct JavaScript number format?
- How to display random numbers less than 20 in Java

Advertisements