Divided by Zero

Divided by Zero

刁瑞's picture

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.
oshapovalov's picture

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

john_e_lilley's picture

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?

oshapovalov's picture
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

john_e_lilley's picture

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

Login to leave a comment.