Boost logo

Boost :

From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2003-04-27 09:00:28


"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.

Speaking about quantity.hpp uploaded to Yahoo: it is general purpose and
lightweight utility to help with conversions. It doesn't know angles or
currencies or SI. I prefere to use example of convering between screen pixel
and image point - something application specific what cannot be known and
implemented in advance by library writer.

Conversion between well known physical units is covered by SIunits (and
other libraries) and quantity.hpp doesn't try to compete with these.

Another examples:
- You may need to know date when one currency value was converted into
another (to find exchange ratio): quantity.hpp may help here to keep details
separated from application code.
- Conversion between angle and geometric point (contrived application
specific example).
- 'Dynamic' conversions: currency is converted into another using available
realtime exchange rate.
- 'Lossy' and 'one way' conversions: rounding up to nearest $ and
(intentionally) with no conversion back.

I am interested if such a utility will be found useful. It is very simple
code (just few constructors + cast operators + naming convention) but the
name quantity probably gives expectations of very specific functionality. I
may change the name ("Safer Value Conversions" would be better but is
wordy).

/Pavel


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