Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
laziness, impatience, and hubris
 
PerlMonks  

Re: numeric values acting funny

by VSarkiss (Monsignor)
on Dec 10, 2004 at 21:03 UTC ( [id://414046]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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 10, 2004 at 21: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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://414046]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.