Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^5: How can I calculate the right combination of postage stamps?

by gwadej (Chaplain)
on Nov 28, 2008 at 19:27 UTC ( [id://726654]=note: print w/replies, xml ) Need Help??


in reply to Re^4: How can I calculate the right combination of postage stamps?
in thread How can I calculate the right combination of postage stamps?

This issue is caused by binary floating point. But, it is an artifact of any floating point notation. For example,

1/3 + 1/3 + 1/3 != 1

for any finite number of digits using decimal representations.

Given any base, there will be some fractions that cannot be properly represented and would therefore cause this problem. (At least until such time as we have infinite precision floating point representations.<grin/>)

G. Wade
  • Comment on Re^5: How can I calculate the right combination of postage stamps?
  • Download Code

Replies are listed 'Best First'.
Re^6: How can I calculate the right combination of postage stamps?
by tilly (Archbishop) on Dec 02, 2008 at 03:24 UTC
    This problem can be solved with Continued Fractions. Unfortunately nobody seems to use continued fraction libraries.

    I know that MJD wrote one in Perl, but he didn't polish it up and release it on CPAN. I don't think anyone else has released one either.

Re^6: How can I calculate the right combination of postage stamps?
by repellent (Priest) on Dec 01, 2008 at 18:11 UTC
      At least until such time as we have infinite precision floating point representations.

    I believe there have been efforts to represent p-adic numbers. perlnumber makes a brief mention of "exotic" number operations with p-adic arithmetic.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://726654]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-24 13:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found