C++ significant figures

This should get you what you need:

std::cout.precision(x); // x would be the number of significant figures to output

This may not be the most efficient way, but you can create a custom sig fig data type.

class SigFigFloat
{
  SigFigFloat(vector<short> digits, int decimalIndex, bool negative);
  SigFigFloat operator+(const SigFigFloat &value);
  SigFigFloat operator-(const SigFigFloat &value);
  //etc...


}

It can be a lot of work, but if you implement this right, it can be a really flexible way to represent and do calculations with sig figs.