Is that what you want? Here, we calculate the amount of available precision and set ostream accordingly.
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char* argv[])
{
// Input
double value = 102.1213239999;
// Calculate limits
int digits = ( (value<1) ? 1 : int(1+log10(double(abs(value)))) );
int width = 10;
int precision = (((width-digits-1)>=0) ? (width-digits-1):0);
// Display
cout.setf(ios::fixed);
cout.precision(precision);
cout<<setw(10)<<value<<endl;
return 0;
}
OUTPUT: 102.121324
Btw, if you want a truckload of ways to compute digits, here's how.