Re: Division of large negative number leads to integer overflow



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
.



Relevant Pages

  • Re: DAT playback issue- refresher course needed
    ... and the interfaces are nonstandard and do not actually ... They will usually work with most AES/EBU devices ... off of hours and hours of tapes (recorded on many different machines), ... standard digital I/O and a reliable transport. ...
    (rec.audio.pro)
  • Re: Integers and standard
    ... The standard can't assume that no ... Yes, the standard doesn't specify which machines exist, ... committee), the implementor, and the user. ...
    (comp.lang.fortran)
  • Re: Accessing Apps through RWW
    ... It is Standard with 2 nics. ... When I setup the machines using the connect ... computer wizard I got a message stating that I am not authorized to view this ...
    (microsoft.public.windows.server.sbs)
  • Re: LSE64 in standard Forth
    ... complement machines for ages, so it's simply the same thing as with C: ... two's complement unless you are on a really exotic piece of hardware. ... But in Standard Forth it's not well defined, not because of the two's complement issue, but because of the size. ... Three of the four C implementations listed in K&R edition 1 are 8/16/32 bit machines. ...
    (comp.lang.forth)
  • Re: Questions, please
    ... But the standard itself is a human construct. ... So why does the standard specify that -1, of all things, must cast to ... on these machines the cast ...
    (comp.lang.c)