For finance and certain other uses, the easiest way is to work in multiples of your smallest unit... in your example, it might be "microns":
inline long long units_to_microns(long long units) { return units * 1000000; }
long long digit = units_to_microns(1);
long long result = digit / 1000000;
Then write some custom code to print numbers a decimal point where you want it:
std::string microns_to_string(long long microns)
{
std::ostringstream oss;
oss << microns / 1000000;
if (microns % 1000000)
oss << '.' << std::setfill('0') << std::setw(6) << microns;
return oss.str();
}
A more structured (and reliable) way to do this is offered by the boost Units library. That way, you can specify the units of specific variables, and if e.g. one was in metres and another kilometres, you could add them without any special care.
If you're dealing with irrational numbers and rounding them off to a specific precision early on is not useful, then you're best off either using double
(for some more significant digits of precision), or a custom library like GMP - the GNU Multiple Precision Arithmetic Library.
BTW - What Every Computer Scientist Should Know About Floating-Point Arithmetic is commonly recommended reading in this space.