Integer division by zero results in floating-point exception !?

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun Apr 1 10:41:59 PDT 2007


"David Finlayson" <david.p.finlayson at gmail.com> wrote in message 
news:euom4m$2lmg$1 at digitalmars.com...
> Why does the following code result in a floating-point exception?
>
> /**
> * PROGRAM: div0.d
> *
> * Test integer division by zero
> */
> import std.stdio;
>
> void main(char[][] args)
> {
>    int a = 2;
>    int b = 0;
>
>    writefln("a/b = ", a/b);
> }
>
> $ bud div0.d
> $ ./div0
> Floating point exception (core dumped)
>
>

Maybe it depends on the system?  On Windows I get the error "Integer Divide 
by Zero". 




More information about the Digitalmars-d-learn mailing list