How to generate NaN float value in C

2 Answers

0 votes
#include <stdio.h>
#include <math.h>

int main(void)
{
    float f;

    f = nanf("");

    printf("%f", f);

    return 0;
}




/*
run:

nan

*/

 



answered Jul 30, 2022 by avibootz
0 votes
#include <stdio.h>
#include <math.h>

int main(void)
{
    float f = NAN;

    printf("%f", f);

    return 0;
}




/*
run:

nan

*/

 



answered Jul 30, 2022 by avibootz

Related questions

2 answers 125 views
125 views asked Jul 30, 2022 by avibootz
1 answer 126 views
2 answers 147 views
3 answers 175 views
1 answer 124 views
124 views asked Jun 1, 2022 by avibootz
...