G
Gary Wessle
hi
the code below is giving me what I want but it is very ugly. and will
not work for a long list of different length numbers.
could you please look at it and comment.
thank you
the desired output is:
0.555504 of an inch foreach 12.55
#include <iostream>
using std::cout;
using std::endl;
#include <iomanip>
using std::setw;
using std::left;
using std::setprecision;
#include <cmath>
using std::log10;
int main(){
double a = 0.5555040000;
double b = 12.5500;
int aa = 1000000;
int bb = 10000;
int za = static_cast<int> (log10(aa));
int zb = static_cast<int> (log10(bb));
cout << setw(10) << setprecision(za) << left << a << "of an inch foreach "
<< setw(10) << setprecision(zb) << b << endl;
}
the code below is giving me what I want but it is very ugly. and will
not work for a long list of different length numbers.
could you please look at it and comment.
thank you
the desired output is:
0.555504 of an inch foreach 12.55
#include <iostream>
using std::cout;
using std::endl;
#include <iomanip>
using std::setw;
using std::left;
using std::setprecision;
#include <cmath>
using std::log10;
int main(){
double a = 0.5555040000;
double b = 12.5500;
int aa = 1000000;
int bb = 10000;
int za = static_cast<int> (log10(aa));
int zb = static_cast<int> (log10(bb));
cout << setw(10) << setprecision(za) << left << a << "of an inch foreach "
<< setw(10) << setprecision(zb) << b << endl;
}