Boost logo

Boost :

From: Victor A. Wagner Jr. (vawjr_at_[hidden])
Date: 2004-09-27 11:04:38


OOps
At Monday 2004-09-27 01:02, you wrote:
>At Sunday 2004-09-26 17:35, you wrote:
>> > Victor A. Wagner Jr. <vawjr_at_[hidden]> wrote:
>> > The midpoint between them is (this is legal using your constraints):
>> >
>> > a + (b-a)/2
>> >
>> > 1st year algebra teaches us that this is equivalent to:
>> >
>> > (a+b)/2
>> >
>> > While on most systems the intermediate value (a+b) would be useless, as
>> > soon as you divide by 2 it again becomes useful.
>> >
>> > with a third pointer (T* c;):
>> >
>> > (a+b+c)/3
>> >
>> > becomes calculable and useful though clearly
>>
>>Just a small $0.02...
>>
>>(a + b) is a dangerous thing in a 32 bit world full of arithmetic
>>overflow opportunities. You'd have to have a very good reason for
>>doing it this way I'd think.
>>
>>a + (a-b) / 2 is a bit safer
>
>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

I should know better than to try this stuff at 0100 local. Of course (b-a)
is less likely to overflow than (a+b). It's certainly fair to presume that
the _size_ of any such container will be small in comparison to the range
addresses

>>matt
>>matthurd_at_[hidden]
>>_______________________________________________
>>Unsubscribe & other changes:
>>http://lists.boost.org/mailman/listinfo.cgi/boost
>
>Victor A. Wagner Jr. http://rudbek.com
>The five most dangerous words in the English language:
> "There oughta be a law"
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>

Victor A. Wagner Jr. http://rudbek.com
The five most dangerous words in the English language:
               "There oughta be a law"


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