Boost logo

Boost :

From: Andras Erdei (aerdei_at_[hidden])
Date: 2005-03-10 02:51:12

On Mon, 7 Mar 2005 17:50:48 -0700, Jonathan Turkanis
<technews_at_[hidden]> wrote:

> I can't tell what template parameters you think rational should have.

(it is because i don't know myself :O)

i think we need two parameters: one for specifying the precision,
and one for specifying the variant to use

the problems:

1. if we specify the precision as an integer, e.g. rational<1000> meaning a
rational with numerator range (-1000,1000) and denominator range (1,1000),
then we restrict the possible underlying types to the integer type used as
the template parameter (and smaller)

a possible workaround is to specify the log of the limits instead, so e.g.
rational<31> would mean (-2^31,2^31) and (1,2^31) -- this is less flexible,
than the above one, but i can't come up with anything better

2. i don't know how can we implement the selection of UDTs: let's say
i have implemented a modular arithmetic bigint type, with up to a few
hundred bits of precision -- how can i tell rational that it can select this
as the underlying type?
> The above declaration was based on the assumption that multiple rounding
> policies should be supported. If there's only one way to round, then rounding
> can be merged into the checking policy.

i don't see how this depends on having more than one kind of rounding:
either you round, or you check, cannot do both at the same time -- do i
miss something?


Boost list run by bdawes at, gregod at, cpdaniel at, john at