Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: numeric values acting funny

by VSarkiss (Monsignor)
on Dec 11, 2004 at 02:03 UTC ( #414046=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://414046]
help
Chatterbox?
and dust plays in a shaft of sunlight...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2018-05-24 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?