Hacker News new | ask | show | jobs
by chongli 386 days ago
Then you calculate the decimal expansion to the desired number of decimal places. This avoids accumulation of roundoff errors in intermediate results.

Note that writing sqrt(2) as 1.41 or 1.41421 or any other decimal expansion you might want to write is incorrect: you will always get some roundoff error. If you want to calculate that sqrt(2)*sqrt(2)=2 then you can’t do so by multiplying the decimal expansions.