#include <math.h>
void main() {
double a = 0;
a += 5e308;
a -= 3.5e308;
if (a == INFINITY) {
printf("1 %en", a);
}
else
printf("0 %en", a);
}
Here, the first print line is what I expect but why is the second print statement executed?
I think a
should be positive infinity as infinity -3.5e308 should be positive infinity, right in line 4?
I have already tried to execute it but the output is:
0 -1.#IND00e+000
I would like to know where my logic goes wrong.
New contributor
Hari Haran is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1