Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,885 questions

51,811 answers

573 users

How to determine if float numbers x and y are unordered (one or both are NaN) in C

1 Answer

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

int main(void)
{
    printf("isunordered(NAN, NAN)       = %d\n", isunordered(NAN, NAN));
    printf("isunordered(NAN, 1.0)       = %d\n", isunordered(NAN, 1.0));
    printf("isunordered(1.0, NAN)       = %d\n", isunordered(1.0, NAN));
    printf("isunordered(1.0, 0.0)       = %d\n", isunordered(1.0, 0.0));
    printf("isunordered(1.0, -983474.0) = %d\n", isunordered(1.0, -983474.0));
}




/*
run:

isunordered(NAN, NAN)       = 1
isunordered(NAN, 1.0)       = 1
isunordered(1.0, NAN)       = 1
isunordered(1.0, 0.0)       = 0
isunordered(1.0, -983474.0) = 0

*/

 



answered Feb 11, 2023 by avibootz
...