
Boost : 
Subject: Re: [boost] [mplcf] [RFC] MPL Real Numbers using Continued Fractions
From: Karsten Ahnert (karsten.ahnert_at_[hidden])
Date: 20101130 10:11:06
> Actually, ignore that statement. You only need two integers for a0 +
> 1/a1, in general you need more. For example, if you look at the test
> program (basic.cpp in the archive), it provides some examples (where the
> floatingpoint output is float, double, long double):
>
> 3/2 + 1/4 = [ 1 1 3]
> 1.75
> 1.75
> 1.75
>
> 1/7 + 1/15 = [ 0 4 1 3 2 2]
> 0.209524
> 0.20952380952381
> 0.209523809523809524
>
> There are other continued fraction representations where any rational
> can be represented with a fixed number of integers (a0 + b0/(a1 + ...)),
> but the algorithms are a little more complicated, and I fear the compile
> times would increase.
I was looking for something very similar to that, altough I believe
compile times are to long for realistic problems. Especially the example
with sine and cosine took approximately 10 minutes on my PC. But who
knows? Maybe compilers are fast enough in some years...
I have also two little questions:
1. Can one express for example 1.25e10 in an easy manner, for example
by simply specifying the exponent?
2. Can one use different representations of rational number, maybe
boost::ratio? I guess this could be difficult to work with the
elementary operations.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk