Java switches a double or float to scientific notation when the ordinary decimal form would be too long, so 10000000.0 prints as 1.0E7 and 6210001000 stored as a float prints as 6.210001E9. To get rid of it, format the number explicitly: String.format("%.0f", value) or BigDecimal.valueOf(value).toPlainString() for text output, or manipulate the string when the exponent is already baked into stored data. You can’t flip a flag on Double.toString itself — you have to choose a different conversion. The right fix depends on whether the number is still numeric or already exists as a string like "1.0E7".
That distinction is the whole ballgame. Formatting a live double is easy and exact enough for display. Parsing and rewriting an existing scientific-notation string is also easy, but the digits you get back may not match what a human expected, because the string is all that survived. And if the value is going into JSON, a database column, or a spreadsheet, the “get rid of” step belongs at a different layer. Below are the workable routes, what each one actually guarantees, and where each breaks.
Why Java uses scientific notation in the first place
Double.toString and Float.toString don’t try to be pretty; they try to be short and round-trippable. The specification behind them (the Double.toString(double) contract in the Java API) requires enough digits to uniquely distinguish the value from its neighbors, and it permits computerized scientific notation when the magnitude falls outside a certain range. In practice, plain decimal notation appears roughly between 10⁻³ (inclusive) and 10⁷ (exclusive). At or above 10⁷ you get an E, and below 10⁻³ you get one too. That’s why 9999999.0 prints plainly but 10000000.0 prints as 1.0E7, and why 0.001 prints as 0.001 while 0.0001 prints as 1.0E-4.
Two consequences follow. First, the threshold is about the printed representation, not the value’s precision — a double holding exactly 10,000,000 is not “too big” for Java, it’s just outside the plain-notation window. Second, float is much narrower: it carries about 7 significant decimal digits, so a value like 6210001000 can’t be held precisely and comes back as 6.210001E9. No formatter can restore digits the float never stored. That’s a data-type problem, not a formatting problem.
There’s also a quieter trap. Double.toString and String.format are different machines. Double.toString produces the shortest string that round-trips; String.format("%f", …) produces a fixed number of digits after the decimal point, rounded. If you format 0.1 + 0.2, you may see 0.30000000000000004 from the first and 0.300000 from the second. Neither is “wrong,” but they answer different questions.
Decide what you actually have before touching anything
The most common wasted hour in this problem is formatting the wrong thing. Sort your situation into one of these before writing code.
| What you have | Example | Correct approach |
|---|---|---|
| A live numeric value you’re printing | double d = 1e7; | Format it at output time |
| A String already in scientific notation | "1.0E7" from a file or API | Parse to a number, then format plainly |
| A value destined for JSON | {"amount": 1.0E7} | Configure the serializer, not toString |
| A value in a database column | 1.0E7 in a VARCHAR | Fix at write time; migrate existing rows |
| A BigDecimal | 1E+7 | Use toPlainString() |
| A value inside a List or array printed with toString | [1.0E7, 2.0E7] | Format each element; the container’s toString won’t help |
If you’re looking at System.out.println(someList), you’re seeing AbstractCollection.toString, which calls each element’s toString. Fixing the element type’s formatting is the only lever; there’s no global switch.
Formatting a live double or float without an exponent
String.format and printf
The direct answer for display is a format specifier. %f never uses scientific notation; it always prints plain decimal, with a default of six digits after the point.
The precision after the dot controls rounding, and , adds grouping separators. %f throws IllegalFormatConversionException if you hand it an integer type, so pass a double, float, or Double/Float. For a float, the value is widened first, which is why String.format("%.0f", 6.210001E9f) gives you 6210001000 but String.format("%.0f", 6.210001E9f) on a value that lost precision earlier may still surprise you — check the float itself, not just the format.
%e is the opposite: it forces scientific notation. That’s useful to know because it means the choice is entirely yours once you format. The one thing %f won’t do is cope gracefully with enormous magnitudes. A double near 1.8E308 formatted with %.0f produces a string over 300 characters long. That’s correct, just not useful; for such values, plain decimal is usually the wrong presentation anyway.
BigDecimal.toPlainString and DecimalFormat
BigDecimal has an explicit method for this, which is why it’s the cleanest tool when the value is already a BigDecimal:
Note that the constructor takes a String here on purpose. new BigDecimal(1e7) goes through double and can carry binary artifacts; BigDecimal.valueOf(1e7) is the safer numeric route because it goes through Double.toString first. For a double, BigDecimal.valueOf(d).toPlainString() is a solid, readable one-liner that never emits an exponent. The catch is scale: BigDecimal.valueOf(1e7) has scale 0 and prints 10000000, but a value like 1.23e-8 prints 0.0000000123 — correct, and long.
DecimalFormat gives you the most control and is the right choice when locale matters:
A pattern of 0.###### prints at least one integer digit and up to six fraction digits, with no exponent. DecimalFormat is not thread-safe; create one per thread or guard it. It also rounds, so decide your precision before you pick the pattern. And be aware it’s locale-sensitive by default — in a German locale, 1.5 becomes 1,5, which will break a downstream parser expecting a dot. Use DecimalFormatSymbols or Locale.ROOT deliberately.
The printf route and when it’s enough
If the only goal is console output for debugging, System.out.printf("%.4f%n", value) is fine and throws nothing. If the goal is a string that another system will parse, prefer BigDecimal.toPlainString() with an explicit scale or a DecimalFormat bound to Locale.ROOT, because you control the decimal separator and the rounding.
When the exponent is already in a String
This is the case that produces most of the frustration, because people search for “remove E from Java string” and get advice about formatting a double they don’t have.
Double.parseDouble accepts scientific notation, including a leading sign and an exponent with a sign, so "‑1.5E‑4" (ASCII hyphen) becomes -0.00015 and toPlainString gives -0.00015. If you want to keep the exact decimal text rather than go through binary floating point, parse straight into BigDecimal:
That route never loses digits, and it works for values far beyond double’s precision, like "1E+400". The double route is simpler and fine for ordinary magnitudes, but remember it’s a lossy round trip for very long decimal strings. If the input has more than ~15–17 significant digits, prefer BigDecimal.
If you must do it with text manipulation and no parsing — say the string is malformed in a way you need to preserve — you can split on E/e, parse the mantissa and exponent, and shift the decimal point yourself. It’s more code, more edge cases (signs, zero mantissa, no decimal point in the mantissa), and rarely worth it. Parsing and re-formatting is shorter and more obviously correct.
One legitimate text-only case: you want to strip a trailing exponent that is purely cosmetic on an integer, like "1.0E7" → "10000000", and you know the mantissa always has exactly one digit before the dot. Even then, a parser is safer.
JSON, databases, and other layers that reintroduce E
Formatting at System.out doesn’t help if the number then goes into JSON and the serializer writes 1.0E7. Jackson, for example, formats double values through its own number handling, and by default may use scientific notation for large or small magnitudes. The settings you actually need live with the serializer:
Jackson: JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, or annotate the field to be serialized as a String, or configure the ObjectMapper’s number formatting. If your type is BigDecimal, the plain feature applies; if it’s double, you may need a custom serializer or to write the value as a string. Gson: GsonBuilder.setPrettyPrinting() doesn’t change number format; use a custom TypeAdapter or serialize the field as a string. Plain StringBuilder JSON assembly: format the value with BigDecimal.toPlainString() before appending.
For databases, the fix is at write time. If a column is a numeric type (DECIMAL, NUMBER), the database stores the value, not the notation — the E you see is the client tool’s display. If the column is VARCHAR and already contains "1.0E7", you need a migration: parse each value and rewrite it, and consider whether the column should have been numeric all along. Changing a VARCHAR column’s display isn’t possible through SQL formatting alone if the string is literally stored that way.
A parallel trap exists with String.valueOf(someDouble), which delegates to Double.toString and therefore reintroduces the exponent. So does concatenation: "" + 1e7 gives "1.0E7". Every implicit string conversion in Java for floating-point types uses that same representation. The formatter must be explicit; there is no global override.
Precision traps that look like formatting bugs
Two failures dominate the “I formatted it and it’s still wrong” reports.
The first is float precision. float has 24 bits of significand, roughly 7 decimal digits. Store 6210001000 in a float and the nearest representable value is not that integer; it’s 6.210001E9. Converting to double and formatting plainly yields 6210001000 or 6210000896 depending on the exact path, and neither is the original. The fix is to use double (about 15–17 significant digits) for identifiers and money-like values where exactness matters, or long/BigInteger for integers. This is why an ID like a phone number should never be a float.
The second is binary floating-point representation. 0.1 is not exactly one tenth in binary. String.format("%.2f", 0.1 + 0.2) gives 0.30, which looks right, but Double.toString(0.1 + 0.2) gives 0.30000000000000004. If exact decimal arithmetic matters — prices, account balances, tax — use BigDecimal with string constructors and explicit rounding modes (RoundingMode.HALF_UP is the common choice for currency, but the applicable rule is a business decision). Formatting a double to two decimals hides the binary artifact; it doesn’t remove it from the calculation.
A third, subtler failure: String.format("%.0f", 2.5) and String.format("%.0f", 3.5) both go to even under some rounding conventions, which can produce 2 and 4. If you need a specific tie-breaking rule, set it explicitly rather than relying on defaults.
A worked check you can reproduce
Suppose you have a double that prints as 1.23456789E8 and you want 123456789. Here’s the reproducible path, with the arithmetic visible.
The value 123,456,789 is exactly representable in double because it’s under 2⁵³ (about 9.007×10¹⁵), so no digits are invented. If you instead had 123456789012345678.0, the double cannot hold it exactly; %.0f may print a nearby integer ending in ...152 or similar, and BigDecimal.valueOf shows the value the double actually contains. To preserve the full input, keep it as a BigDecimal or long from the start. That’s the general rule: formatting never recovers precision, it only reveals or conceals it.
A quick self-check after any fix: round-trip the output. Double.parseDouble(formatted) should equal your original (within a tick), and the formatted string should contain no E or e. If it parses back to something different beyond rounding, you have a precision problem, not a notation problem.
Choosing between the approaches
Use String.format("%.0f", …) or a DecimalFormat pattern for console and report output where you control precision and locale. Use BigDecimal.toPlainString() when the type is already BigDecimal or when you’re handling values that exceed double’s precision. Use serializer settings when the destination is JSON or XML. Use a data-type change (double, long, BigInteger, BigDecimal) when the real problem is that a float or a binary floating-point representation can’t hold the value. And when the exponent lives in a string, parse it — don’t scrape it.
The limits are consistent across all of them: none can produce digits the stored value doesn’t have, none changes the value itself, and none applies globally to every implicit toString. You’re always choosing a conversion at a specific point in the data flow. Find that point, and the exponent disappears exactly once, in the right place.