Boost logo

Boost :

From: Martin Bonner (martin.bonner_at_[hidden])
Date: 2006-06-01 04:47:42


----Original Message----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_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
> a-b
> 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 non-negative integers.

a-b is defined as the value x such that b+x is equal to a.

For non-negative integers that means a-b is only defined if a >= b.

I would argue that -a is not really meaningful for non-negative
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.

non-negative 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

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk