I am trying to use memset with INFINITY or NAN present in C header file <math.h> My code is:
double *dist;
dist = (double *)malloc(7*sizeof(double));
memset(dist, INFINITY, 7*sizeof(dist[0]));
However, on execution it gives me the following errors:
main.c:10:18: warning: overflow in conversion from ‘float’ to ‘int’ changes value from ‘+Inff’ to ‘2147483647’ [-Woverflow]
11 | memset(dist, INFINITY, 7*sizeof(dist[0]));
But I know INFINITY and NAN is represented using float. So why is it giving me an error? I even tried by using float instead of double but same issue. But, with any other floating point values it is working perfectly. Please help.
P.S.: It works perfectly fine if I use a loop instead of memset.
Edit: Is there any other way of doing this by avoiding the loop?