There are libraries for fixed point arithmetics available. What they do is that they store numbers in a custom format (like storing digits separaterly) and guarantee you the exact precision you declare. The downside is that calculations using such numbers are much slower because they have to be implemented in software.