C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Newbie] Anzahl der ausgegebenen Nachkommastellen festlegen?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Moritz Wade
Guest





PostPosted: Sat Feb 12, 2005 10:35 pm    Post subject: [Newbie] Anzahl der ausgegebenen Nachkommastellen festlegen? Reply with quote



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





PostPosted: Sun Feb 13, 2005 8:40 am    Post subject: Re: [Newbie] Anzahl der ausgegebenen Nachkommastellen festle Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.