0en abschneiden
-
Hab ich ne Chance, Fließkommazahlen 'normal' darzustellen. D.h. so wie ichs eingeb ohne dass bis zur gewählten Genauigkeit mit Nullen aufgefüllt wird und ohne dass es bei großen Zahlen eine Exponentialschreibweise gibt?
#include <iostream>
#include <iomanip>
using namespace std;int main(int argc, char* argv[])
{
double d1( 123.3425345);
double d2( 123124234234.34);
double d3( 12.11124);
double d4( 1.1);cout << d1 << endl;
cout << d2 << endl;
cout << d3 << endl;
cout << d4 << endl;cout.precision(25);
cout << d1 << endl;
cout << d2 << endl;
cout << d3 << endl;
cout << d4 << endl;cout.setf( ios_base::fixed);
cout << d1 << endl;
cout << d2 << endl;
cout << d3 << endl;
cout << d4 << endl;return 0;
}Wenns zu rundungsfehlern kommt ist es kein Problem. Es sollte so aussehen, wie's ohne Formatstrings ist, nur dass die große Zahl hier halt ein 'e' hat.