PyTorch uses floating-point to store decimal number. Due to the structure of floating-point the numbers are not stored properly and it causes precision loss.
Structure of floating point 16
I was thinking about using integers to perform math operations and then use the new object to store those numbers to preserve the decimal points without any precision loss.