Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The exchange rates are fixed and are offical Euro exchange rates. The invoice total, before conversion, equals the sum of the line items. After conversion they differ by a penny or so. I need to be sufficiently precise so that they are equal after conversion.
Maybe you don't get that this is not always possible. For example, consider a series of transactions of 103, 103, and 104 units. Those added together make 310 units. Now convert those into a currency that is 1/10 the size. We round 10.3 to 10 (twice) and 10.4 to 10 (once). The "total" should be 31, but it's really only 30. This is the way this works. You cannot always balance to the penny when you map values from one currency to another and it's considered fair accounting practice to simply note that and move on.

A parallel example: my brother noted that at a particular Washington State sales tax rate, it was cheaper by a penny to buy two single Big Gulps rung up separately than it was to buy them as a combined transaction. So whenever he had to buy two, he'd always buy one, pay, then buy the second one.

This is the real world, and it's accepted practice. Don't attempt the impossible. {grin}

-- Randal L. Schwartz, Perl hacker

In reply to Re: Re: Re: Rounding errors problem by merlyn
in thread Rounding errors problem by perlcgi

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-05-22 22:13 GMT
Find Nodes?
    Voting Booth?

    No recent polls found