How to Round to Arbitrary Precision in any Programming Language: an AMultiply your rounding number by 10^y where y is the precision to round to. Call your language’s built-in round() method on this number. Divide the result by 10^y. Easy peasy. It also makes it easier to implement different rounding methods because you’re always dealing with the digit at the same location in the number.
Tag: programming
The right tool for the right job: Not so simple.
The right tool for the right job, like most things in life, is more complex, more difficult to understand, and takes effort to grasp the reason and benefits of its true meaning.