in reply to numeric values acting funny

Your problem isn't in Perl, but in how numbers are represented.

There's an old rule in numerical analysis:

Never subtract very close values from each other
The problem, in very basic terms, is that your variables are the value you want, plus or minus some small "epsilon". If you subtract two very close values, all you end up with is ε1 ± ε2; in other words, garbage.

Your best bet is to restructure the formulas so the subtraction isn't necessary.

Replies are listed 'Best First'.
Re^2: numeric values acting funny
by tachyon (Chancellor) on Dec 11, 2004 at 02:09 UTC

    Your best bet is to restructure the formulas so the subtraction isn't necessary.

    This is I believe impossible given that the task rotates around money and spending some quantum of the available. Using integer math is probably a more practical solution. Math::Currency provides a nice transparent implementation that simulates dollars and cents, pounds and pence.....

    cheers

    tachyon