infinity and nan values
Pregunta
I use gcc-mingw,4.5.2 on Winows 7. printf of infinity and nan values causes 1.#INF00 and -1.#IND00 to appear in the screen ,instead of infinity && nan what could be a solution for this problem
UPD:I tried to use isinf
and isnan
macros :
C3861: 'isinf': identifier not found error
C3861: 'isnan': identifier not found.
(I did include to math.h) What is the reason for this?
Solución
Use the isinf()
and isnan()
macros to test wheter a number is an infinite or a NaN.
Otros consejos
Add the following to your program.cpp
#ifndef isinf
#define isinf(x) ((x)!=(x))
#endif
#ifndef isnan
#define isnan(x) ((x)!=(x))
#endif
That's just how the standard library of your compiler treats those special values. If you want different treatment you need to write your own print function that detects the special values and prints the text that you desire.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow