Scientific Notation for Floating-Point Literals
What you'll learn: How to write very large or very small floating-point numbers compactly using exponential notation with e or E.
The Core Idea
When working with extremely large or tiny decimal numbers, writing out all the zeros becomes tedious and error-prone. Java lets you express floating-point literals using scientific notation, just like you'd see in mathematics or science class. Instead of writing 123000.0 or 0.000123, you can use the e or E character to mean "times 10 to the power of."
How It Works
The format is: [number]e[exponent] or [number]E[exponent]
The number before e is the mantissa (or coefficient), and the number after is the exponent—how many places to move the decimal point.
double largeNumber = 1.23e5; // means 1.23 × 10^5 = 123000.0
double smallNumber = 1.23e-4; // means 1.23 × 10^-4 = 0.000123
double speedOfLight = 2.998E8; // 299,800,000.0 meters per second
Positive exponents shift the decimal right (making numbers larger); negative exponents shift it left (making numbers smaller).
You can combine scientific notation with type suffixes:
float distance = 3.5e6f; // 3,500,000.0 as a float
double tiny = 4.2e-9; // 0.0000000042 as a double
Key Takeaway: Use e or E in floating-point literals to express numbers in scientific notation, making very large or small values readable and compact—the exponent tells Java how many decimal places to shift.