Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-04-28 00:46:11


>From: "Robert Ramey" <ramey_at_[hidden]>

> assume that each currency has a function that can convert into a canonical
> measure of value such as dollars, swiss francs or gold.

<snip>

> Just a rough sketch, but I believe the idea should be clear

Yes. I didn't wonder about how to implement it, as that's quite simple. What
I wondered was if it could be implemented this way, and still get correct
results (i.e. the same as you could get from a bank). For example, if each
country determined independently the conversion rate from their currency to
the other ones, then there would be no guarantee that converting from A to B
to A would yield the same result. Moreover, even if they used the same
rates, there might be a slight difference in the value you got after such a
rund-trip, anyway (analoguos to that if you sell a stock, and then buy it
back at once, you'll typically get less than what you started with).
However, when testing this with conversion calculators on the Internet, A to
B to A gives the same value back, so it seems this is ok. A bank would
typically charge an amount to do the currency conversion, though, but that
could also be modelled this way.

Thanks.

Regards,

Terje

> >From:Terje_Sletteb>From: "Pavel Vozenilek" <pavel_vozenilek_at_[hidden]>
>
> >> "Terje Slettebø" <tslettebo_at_[hidden]> wrote in message
> >> news:01fe01c30ca7$1aa134b0$8d6c6f50_at_pc...
> >> > If one were to implement currency conversion, how might that be done,
in
> >> > general?
> >> >
> >> > Does one need to store the conversion rates between any two
currencies
> >> > (giving an N^2 size table), or might it be possible to convert any
> >> currency
> >> > to some "universal currency", and from that again to any other, and
> still
> >> > getting the right values (giving a 2N table)?
> >> >
> >> Currency conversion as drop-in library is IMHO not possible -
currencies
> >> differ from strict units like weight and future applications may
require
> >> functionality beyond current requirements.
>
> >Well, your library is very general, where you provide conversion
functions
> >between any two types. If you define each currency as a type, wouldn't
this
> >cover the functionality for converting between currencies? If not, what
> >could be needed?
>
> >I realise that in this case, it may be a lot of functions to define, to
> >define the conversion between any two currencies - for e.g. 20
currencies,
> >that's around 400 functions to define. I meant if it theoretically would
be
> >possible for your library, since you say you think it's not possible for
a
> >"drop-in library" (what is meant by that?).


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk