$ cat int_div_by_zero.cKaboom! Nothing. This result immediately raises the question, "Is integer math division as slow as or slower than floating point division since it seems to be implemented in terms of it?"
#include <stdio.h>
int main()
{
printf("%d\n", 3 / 0);
return 0;
}
$ gcc int_div_by_zero.c
int_div_by_zero.c: In function 'main':
int_div_by_zero.c:5: warning: division by zero
$ ./a.out
Floating point exception
(We get the same result with 0/0 and also even when we compile with -fno-trapping-math.)
No comments:
Post a Comment