in reply to How to calculate the sum of columns to be equal to 100?

On this exact problem, see summary of solutions for MJD's perl quiz of the week regular #7 from 2002, and an apology about that email containing wrong code. Strangely, I can't seem to find the message where this quiz was posed, nor any solutions sent to the discuss mailing list.

Update: try this search in the archives to find solutions submitted by participants.

  • Comment on Re: How to calculate the sum of columns to be equal to 100?

Replies are listed 'Best First'.
Re^2: How to calculate the sum of columns to be equal to 100?
by Laurent_R (Canon) on Aug 15, 2013 at 13:35 UTC

    Yes, fudging the data is one solution.

    The company for which I work as an independent consultant spent a few years back several hundred thousand euros trying to get their invoices "look right" (about 20 million invoices per month). After a lot of thinking, simulations on Excel, consultations with accountants, auditors and tax advisers, prototyping, etc., it was finally decided that all the invoice individual lines and subtotals would have 5 decimal digits, and only the invoice total (and VAT) would be rounded to the nearest cent. There may still be some rounding differences, but, at least, nobody really cares about a difference of 0.00001 euro.

      I have also seen invoices in which the last line before the invoice total is a "rounding compensation", something like -0.01.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ