 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Moritz Wade Guest
|
Posted: Sat Feb 12, 2005 10:35 pm Post subject: [Newbie] Anzahl der ausgegebenen Nachkommastellen festlegen? |
|
|
Hallo NG,
mit
cout.precision(x);
kann ich die Anzahl der Stellen der Ausgabe festlegen.
Bei x = 5 wird aus 1.2345678 also 1.2346 und aus 1234.5678 also 1234.6.
Ich habe nun eine Reihe von Double-Zahlen mit vielen Stellen, will
jedoch nicht die Anzahl der Ziffern festlegen, sondern die Anzahl der
Nachkommastellen. Wie kann ich das am einfachsten bewerkstelligen?
Danke,
Moritz
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
Moritz Wade Guest
|
Posted: Sun Feb 13, 2005 8:40 am Post subject: Re: [Newbie] Anzahl der ausgegebenen Nachkommastellen festle |
|
|
Stefan Ram schrieb:
| Quote: | Etwa durch Verwendung von ::std::fixed oder ::std::scientific.
|
Danke, "fixed" hilft mir schonmal deutlich weiter.
Noch schöner wäre es, wenn die gewünschte Anzahl an Nachkommastellen nur
dann ausgegeben wird, wenn es auch so viele relevante Stellen gibt. Ich
würde also gerne eine Auffüllung durch Nullen verhindern. Das ließe sich
ja prinzipiell mit "noshowpoint" realisieren, doch lässt sich das wohl
nicht mit "fixed" kombinieren. Gibt's da eine einfache Lösung?
Danke,
Moritz
--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|