
Boost : 
From: Maarten Kronenburg (M.Kronenburg_at_[hidden])
Date: 20060601 08:20:21
Martin,
This problem is solved,
see below:
The arithmetic member operators
returning integer by value are changed
to nonvirtual.
The virtual integer & operator=(
const integer & );
now has the following note:
"Derived classes must override this
member operator and use it to convert
(temporary) objects of type integer
back to the derived class."
Also it is explained that the
arithmetic nonmember operators and
the arithmetic member operators
returning integer by value must call
integer member functions and operators,
not the derived ones.
Now in expressions with unsigned_integer
variables, temporary results can be
negative. Only when a negative endresult
is assigned, an exception will be thrown.
So when a is 3 and b = 4,
x = a + b;
will not throw an exception.
Regards, Maarten.
"Martin Bonner" <martin.bonner_at_[hidden]> wrote in message
news:D997BF79D1E92C4793B7FCC04B4F90A555D1E0_at_pigeon.pi.local...
> Original Message
> From: boostbounces_at_[hidden]
> [mailto:boostbounces_at_[hidden]] On Behalf Of Maarten Kronenburg
> Sent: 31 May 2006 21:25 To: boost_at_[hidden]
> Subject: Re: [boost] Infinite precision integer draft
>
> > This problem with unsigned_integer
> > throwing an exception when negative
> > is already apparent for the two
> > expressions
> > ab
> > and
> > a+b [presumably b+a is intended]
> [snip]
>
> > a true unsigned infinite precision integer
> > which may or may not throw exceptions in
> > equivalent expressions
>
> But those expressions are not equivalent for nonnegative integers.
>
> ab is defined as the value x such that b+x is equal to a.
>
> For nonnegative integers that means ab is only defined if a >= b.
>
> I would argue that a is not really meaningful for nonnegative
> integers, but the most obvious definition is that a is the value x such
> that a+x = 0. That is only defined for a = 0 (and gives x=0).
>
> Thus your first expression is defined for any b <= a, whereas your
> second is only defined for b=0.
>
> nonnegative integers are not the same as Z (but are still useful).
>
> 
> Martin Bonner
> Martin.Bonner_at_[hidden]
> Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ,
> ENGLAND Tel: +44 (0)1223 203894
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk