Boost logo

Boost :

Subject: Re: [boost] a safe integer library
From: David Stone (david_at_[hidden])
Date: 2015-12-17 21:42:48


Matt:

Matheus Izvekov has created a nice fixed-point library that lets you
specify exact precision. It also interoperates with my bounded::integer
library as one possible back-end.

==Tangent==

For a money type, we often think of money as being any number of dollar
digits followed by exactly two cent digits. I work in finance, however, and
this is not always true. Certain instruments are traded in 1/8 of a cent,
meaning that they would actually require five decimal digits past the point
to represent. Currency conversions (how many US dollars can I buy with one
Euro?) just as bad. They were typically traded in pips, which is 4 decimal
places, but now they are traded in fractional pips, which is 5. There is no
reason to believe that this will remain at 5 forever.

The typical representation in the wire protocol for all of these prices is
to effectively send two integers and treat it as a rational (the wire
representation for those two integers varies, but that is the ultimate
idea).

I don't know how much a "standard" money class should deal with these 'side
issues', as most people don't care about pips and pipettes. However, many
of the people who deal with money the most do, and would be unable to use
fixed_point<a lot, 2> as their underlying money type.


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