In my program some computation could generate 1.#INF00 or -1.#IND00 results
I want to print these results – but not as 1.#INF00 and -1.#IND00 .For example for 1.#INF00 , I want to print “infinity”
infinity_print(computation(x));//results infinity result 1.#INF00
will cause “infinity” to appear on the screen
How infinity_print could be implemented?
You could use isinf(y) macros in c99. Otherwise it depends on your compiler, OS, architecture — different implementations have various drawbacks.
Here’s some of possible variants:
For
float,long doublethe implementations are similar.Example