1 Jun 2006 02:09
Re: Infinite precision integer draft
Maarten Kronenburg <M.Kronenburg <at> inter.nl.net>
2006-06-01 00:09:19 GMT
2006-06-01 00:09:19 GMT
There is another solution: in the binary integer operators the lhs or rhs is cloned, but not the derived member operators are called, but the integer ones. This seems reasonable as the binary integer operators return integers by value anyway. Also the unary operator- returns integer by value, and can call the integer negate(), not the derived one. Only when the result is assigned, the derived operator=( const integer & ) is called, which converts the integer back to the derived class, and in the case of unsigned_integer, throw an exception when the result is negative. This solves our unsigned_integer problem. There is however one price: efficiency. For example for modular_integer, the temporary results are never made modular, so may become larger than when the derived member operators would have been called. So this is another dilemma. But as those integer arithmetic binary and unary operators return integer by value anyway, in my opinion the integer member(Continue reading)
RSS Feed