in reply to Re^4: How to use the int-function?
in thread How to use the int-function?

Because the double precision approximation of 1.255 is slightly below 1.255 and the double precision approximation of 1.455 is slightly above 1.455. You introduce the error during the assignment, not during the manipulation. Ratazong's solution actually introduces additional errors into the process since now you have two approximated numbers, as well as additional maintenance complexity.

Why is your application so sensitive to this change? There are ways to handle it, but this is a consequence of the real hardware you are working with. Depending on your application, you could do all your math with integers, use Math::BigFloat, use Math::BigRat, or tweak your algorithm/order of operations.

Replies are listed 'Best First'.
Re^6: How to use the int-function?
by Anonymous Monk on Jan 03, 2011 at 16:25 UTC
    Thanks, kennethk, I really think you have shed some light on the problem, and I see much clearer now.

    To close my contribution so far, its not that I am stuck with my application, but I was puzzled to not get the most basic arithmetic under my control using a powerful computing device. But as you showed me, its not as easy as "want" to come to the "getter".