From: Yohanes Santoso Date: 2002-12-11T12:12:46+09:00 Subject: Re: warnings -w "Pe�a, Botp" writes: > Isn't it that #to_i and #truncate exhibit odd and therefore dangerous > behaviour? > As a nuby, how do I avoid such "errors"? There really is no easy way to escape such errors. The difficulties lies in how the computer represents the number 0.2. As other posts in this threads shows, 0.2 is one of the numbers that can't be represented correctly. The best representation computer can come up with for 0.2 is: 0.200000000000000011102230246251565404236316680908203125 Thus, when dividing 12.4 with that representation, you actually do not get a whole number. The problems of numerical computation using computer are widely known. In fact, to graduate from Applied Math major in my university, a student has to take _two_ 400-level numerical computation classes just so they know how to do numerical computation correctly. Using spesialised mathematic library like the GNU MP library may help alleviate this problem, but no solution can solve this completely. YS.