Boost logo

Boost :

From: Matt Hurd (matt.hurd_at_[hidden])
Date: 2004-09-27 04:59:52


> Victor A. Wagner Jr. <vawjr_at_[hidden]> wrote:

> I don't see the safety issue and what you showed is incorrect; a + (b-a) /
> 2 is at least correct, but b-a overflows just as readily as a+b

oops, for sure, b-a rather.

I'm missing some understanding, given that b >= a, why is b-a just as
ready to overflow as a+b? I guess you are saying b - a > 2GB
(typical ptrdiff_t) is just as likely as an overflow from a + b, if
it was legal, on a common 32 bit platform for example, or have I
misunderstood?
 
matt.
matthurd_at_[hidden]


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