Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

A project has two tasks

Task A takes 1 hour, Task B task 4 hours.

For this project we enter dollars as the cost currency.

It costs $100/hr, so task A costs $100, and task B costs $400.
Overall the project costs $500

However this project is one of many, each having different currencies, so we would like to convert the costs to the base currency used by all projects, which is euros.

Now the conversion rate is contractually specified per activity, in this case

task A has a conversion rate of 1 euro = 4 dollars
task B has a conversion rate of 1 euro = 2 dollars.

Thus converting task A to euros is

$100 / 4 = 25 euros

converting task B to euros is

$400 / 2 = 200 euros

Thus the entire project is 225 euros.

All seems fine.

However what if things worked the other way. we entered in euros, but want to convert to dollars?

Well task A is 1/5 of the total,

so task A is 225 euros * 1/5 = 45 euros
task B is 225 euros * 4/5 = 180 euros

now converting to dollars

task A is 45 euros * 4 = $180
    task B is 180 euros * 2 = $360

Thus the total cost of the project in dollars is $540

This isn't good. I want this calculation to be reversible but 500isnot540, and that is obviously not just 'rounding error'. There is a flaw in my algorithm.

What do i need to do to make these conversions reversible?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.