Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo Leute,

habe eine "eigentlich" wirklich simple Frage. Und zwar wie deklariere ich eine Variable so, dass nach der Verarbeitung das Ergebnis so weit ausgegeben wird bis das Ergebnis komplett da steht.

		double c = 0;



		cout << "\nGeben Sie nun den Wert an(mm): ";

		cin >> c;


		double d = 0;

		double e = 0;

		double f = 0;

		double b = 0;



		d = c/10;

		e = c/1000;

		b = d/10;

		f = c/1000000;






		cout << "\n" << c << " Millimeter. Das sind: " << d  << " Zentimeter" << endl << endl;

		cout << c << " Millimeter. Das sind: " << b << " Dezimeter" << endl << endl;

		cout << c << " Millimeter. Das sind: " << e << " Meter" << endl << endl;

		cout << c << " Millimeter. Das sind: " << f << " Kilometer" << endl << endl; 

Wenn ich hier in der Umrechnung bei mm 1 angebe kommt bei der Ausgabe von Kilometer das hier heraus: 1e-006 Kilometer.

Ziel ist es, dass das Ergebnis komplett ausgegben wird.

Schon mal im voraus Danke

Gruß

Nooper

Danke für die schnelle Antwort. Danke auch dafür das du mich auf den richtigen Weg geführt hast. Ich habe also im falschen Bereich gesucht...

Werde nun nach anderen Möglichkeiten suchen.

Es gibt zwei Möglichkeiten, Fließkommawerte auszugeben: Die Festpunktschreibweise und die Exponentialschreibweise. Als Voreinstellung entscheidet cout das selbst anhand des Wertes.

Man kann aber auch eine der Möglichkeiten erzwingen, entweder über die setf-Methode des Streams oder über entsprechende Manipulatoren.


cout.setf(ios_base::fixed);
cout << f;

// oder

cout << fixed << f;[/code]

Letzteres erfordert <iomanip>.

Um die Exponentialschreibweise zu erzwingen, gibt es das Flag ios_base::scientific bzw. den Manipulator scientific.

@Klotzkopp: Danke für die Antwort. Es funktioniert.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.