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

Hi,

ich hab hier grad irgendwie Tomaten auf den Augen. Ich find in der MSDN absolut nicht, wie man einen Float oder Double auf 2 nachkommastellen runden kann.

Thnx4Help

hallo!

wenns nur um die ausgabe geht:

...

#include <iomanip.h>

...

int main()

{

cout.setf(ios::fixed);

cout<<setprecision(2);

...

}

...

setprecision legt die anzahl der nachkommastellen fest. es wird jedoch nur bei der ausgabe (cout) auf zwei stellen nach dem komma gerundet.

Hi Leute,

geht der Befehl auch in Delphi?

Original geschrieben von Jester

Hi Leute,

geht der Befehl auch in Delphi?

neee... dafuer kannst du aber ohne weiteres die Funktion Format verwenden...

z.B.

var

S : string;

x : double;

begin

x := 13,813469123;

s := Format(%f.3,[x]);

end;

dann hast du 3 Nachkommastellen... wenn du .3 weglaesst wird standardmaessig mit 2 Stellen gearbeitet... kannst aber eine beliebige Genauigkeit so festlegen

Uruz

geht bestimmt auch so:

char puffer[100];

double double_wert = 1.42565;

sprintf(puffer,"%.02f",double_wert);

double rounded_wert = atof(puffer);

----------

Have fun ...

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.