Messages in this thread | | | Date | Thu, 19 Nov 1998 15:19:45 +0100 (MET) | From | David Weinehall <> | Subject | Re: 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/
| |