Divided by Zero

Divided by Zero

output(1 / 0);

What should the program output ?
NaN ? Error ?

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I think "error, division by zero, line 1"

Agreed, or something similar. However, there some other cases:var x = 1/0; // produce error here?output(x); // or here?var x = pow(10,pow(10,100)); // INF error here?output(x); // or here?

Quoting john_e_lilley
Agreed, or something similar. However, there some other cases:var x = 1/0; // produce error here?output(x); // or here?var x = pow(10,pow(10,100)); // INF error here?output(x); // or here?I think in first step in first and second examples

Judges, do you have a preference that NaN and Inf numbers be detected at evaluation time, or at output time?

Leave a Comment

Please sign in to add a comment. Not a member? Join today