
2 Apr
2005
2 Apr
'05
10:35 a.m.
"Andy Little" <andy@servocomm.freeserve.co.uk> wrote
There is a safe range of values for each operation. eg for an implementation of rational addition where Rationalx = Nx/ Dx and operator + is implemented as :
(N1 * D2 + N2 * D1 ) "/ "(D1 * D2)
FWIW if one limited values to the contiguous range scheme in my previous post, I think that the 'naive' algorithm above (+ rational.normalize() )gives significantly better speed and memory performance than the addition calc in current version of boost::rational. This is probably also true of other operations. The current implementation is making assumptions about the integer used as the value_type, and may not be optimal for a bigint value_type either. regards Andy Little