lkml.org 
[lkml]   [1998]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: have a look at this proggie, please.
On Thu, 19 Nov 1998, Alan Modra wrote:

>
> On Wed, 18 Nov 1998, Tigran Aivazian wrote:
>
> > #include <values.h>
> > #include <stdio.h>
> >
> > int main(int argc, char *argv[])
> > {
> > int a = -MAXINT-1, b = -1, c = a*b;
> >
> > fprintf(stderr, "%d * %d = %d\n", a, b, c );
> > if (b) {
> > c = a / b;
> > fprintf(stderr, "%d/%d = %d\n", a, b, c );
> > }
> > return 0;
> > }
>
> Why the surprise? You've generated an exception #0, which Intel
> called "divide by zero" in early IA processor manuals, but now call
> "divide error". It is raised by any divide where the result overflows.

That's NOT an divide by zero...

Output:

-2147483648 * -1 = -2147483648
Floating exception
^^^^^^^^^^^^^^^^^^
Quite obviously, -MAXINT-1 * -1 is too large for an integer to hold (by
one), but it should *NOT* report a floating exception... Right?!

/David Weinehall
_ _
// David Weinehall <tao@acc.umu.se> /> Northern lights wander \\
// Project MCA Linux hacker // Dance across the winter sky //
\> http://www.acc.umu.se/~tao/ </ Full colour fire </

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:45    [from the cache]
©2003-2011 Jasper Spaans. Advertise on this site