Re: Division of large negative number leads to integer overflow
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Thu, 1 Mar 2007 22:28:32 -0800
Arjen Markus <arjen.markus@xxxxxxxxxx> wrote:
I checked this with two different compilers on Windows XP. Is this
behaviour prescribed
by the standard or is it machine-dependent?
The standard doesn't specify what the valid range of integers is or that
the range is symmetic. Good thing, insomuch as the range pretty much
never is symmetric on current machines.
With pretty much all current machines, the negative of the largest
positivevalue is out of range.
Executing operations whose result is "not defined by the processor's
arithmetic" makes your program nonstandard. Anything can happen.
Aninteger overflow is one real possibility. Getting a bogus value is
another.
I don't find the behavior you observed at all surprising. It is not
specified by the standard, but neither is it prohibitted.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- Follow-Ups:
- Re: Division of large negative number leads to integer overflow
- From: Richard Maine
- Re: Division of large negative number leads to integer overflow
- References:
- Division of large negative number leads to integer overflow
- From: Arjen Markus
- Division of large negative number leads to integer overflow
- Prev by Date: Division of large negative number leads to integer overflow
- Next by Date: Re: Division of large negative number leads to integer overflow
- Previous by thread: Division of large negative number leads to integer overflow
- Next by thread: Re: Division of large negative number leads to integer overflow
- Index(es):
Relevant Pages
|
|