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

David Finlayson david.p.finlayson at gmail.com
Sun Apr 1 09:20:38 PDT 2007


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)




More information about the Digitalmars-d-learn mailing list