Why does this code sometimes return NaN?
Posted
by carrots
on Stack Overflow
See other posts from Stack Overflow
or by carrots
Published on 2010-06-11T09:50:38Z
Indexed on
2010/06/11
17:43 UTC
Read the original article
Hit count: 266
This often returns NAN ("Not A Number") depending on input:
#define PI 3.1415f
GLfloat sineEaseIn(GLfloat ratio) {
return 1.0f-cosf(ratio * (PI / 2.0f));
}
I tried making PI a few digits smaller to see if that would help. No dice. Then I thought it might be a datatype mismatch, but float and glfloat seem to be equivalent:
gl.h
typedef float GLfloat;
math.h
extern float cosf( float );
Is this a casting issue?
© Stack Overflow or respective owner