$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Anthony Williams (anthwil_at_[hidden])
Date: 2002-08-23 03:30:21
Greg Colvin writes:
> At 12:38 PM 8/22/2002, David Bergman wrote:
> >And, obviously, signed integer arithmetics cannot take place in a modulo
> >ring, since such a ring does not include negative numbers...
> >
> >But, that is not a loop-hole for using double-precision in interims,
> >since the positive numbers of "int" (just to take an integral example)
> >have to be a subset of "unsigned int", so see, you still cannot maneuver
> >out of the modulo ring...
> >
> >I.e., it is still invalid of an implementation to do the trick you
> >described.
>
> No, it is perfectly valid. If the product of two ints overflows all
> bets are off.
Which means, as I said before, that a compiler can define it in specific
circumstances --- i.e. they can say "a*b/c" is valid if it yields an in-range
result, even if a*b overflows. Many (x86) compilers will provide a valid
result in this case anyway, because its the fewest instructions, and undefined
behaviour on overflow means they're allowed. If the result still doesn't fit,
they'll generate a divide-by-zero error, which is also allowed as undefined
behaviour.
Anthony