Double ohne Exponent

  • Themenstarter Themenstarter EinJavaAnhänger
  • Beginndatum Beginndatum
E

EinJavaAnhänger

Gast
Hallo zusammen,

kann man dem Double Datentyp irgendwo statisch zuweisen, dass er keine Exponenten zur Darstellung nutzen soll (nie).

Bei großen Zahlen per Decimalformatter das wegzumachen finde ich irgendwie nicht performant.

Es muss doch irgendwie gleich so gehen, oder das man angegeben kann, fang erst bei 1 Milliarde damit an.

Ich habe leider kein Flag oder sowas bei dem Typ gefunden.

Vielen Dank im Vorraus 🙂
 
Ich weiß jetzt nicht, ob das funktioniert, aber hast du schonmal versucht, denn double in ein BigDecimal umzuwandeln? Der müsste doch eigentlich immer alle Stellen anzeigen...
 
Geht nicht einzustellen. Die API-Doc von Double.toString(double) sagt:
If m is less than 10^-3 or greater than or equal to 10^7, then it is represented in so-called "computerized scientific notation." Let n be the unique integer such that 10^n <= m < 10^(n+1); then let a be the mathematically exact quotient of m and 10^n so that 1 <= a < 10. The magnitude is then represented as the integer part of a, as a single decimal digit, followed by '.' ('\u002E'), followed by decimal digits representing the fractional part of a, followed by the letter 'E' ('\u0045'), followed by a representation of n as a decimal integer, as produced by the method Integer.toString(int).

DecimalFormat ist genau der richtige Weg.

Ich weiß jetzt nicht, ob das funktioniert, aber hast du schonmal versucht, denn double in ein BigDecimal umzuwandeln? Der müsste doch eigentlich immer alle Stellen anzeigen...
Dass das performanter wird bezweifele ich allerdings. ;-)

Ebenius
 
Zuletzt bearbeitet:

Zurück
Oben