Subject: isfinite returning wrong results
From: Yitzchak Scott-Thoennes <[email-masked]>
To: [email-masked]
Date: Wed, 4 Aug 2004 01:10:35 -0700

I'm having trouble figuring this out.  isfinite is sometimes returning
incorrect results.

In one more complicated program, I saw isfinite returning false for
negative 0 and true for -Inf, and otherwise correctly, but once I got
it down to this test case, isfinite, which is just a macro in math.h
that calls fpclassify twice, returns true for everything.  The macro
looks to be completely correct, and fpclassify is working.

$ cat isfin.c
#include <stdio.h>
#include <math.h>

int main(int argc, char **argv) {
  double z = 0;
  double nan = 0/z;
  double inf = pow(9,999);
  double ninf = pow(-9,999);
  double nz = -(long double)0;

  printf("nan %g inf %g ninf %g z %g nz %g\n", nan, inf, ninf, z, nz);
  printf("fpclassify: nan %d inf %d ninf %d z %d nz %d\n", fpclassify(nan),
         fpclassify(inf), fpclassify(ninf), fpclassify(z), fpclassify(nz));
  printf("isfinite: nan %d inf %d ninf %d z %d nz %d\n", isfinite(nan),
         isfinite(inf), isfinite(ninf), isfinite(z), isfinite(nz));

  return 0;
}

$ gcc -o isfin.exe -Wall isfin.c;./isfin
nan NaN inf Inf ninf -Inf z 0 nz -0
fpclassify: nan 0 inf 1 ninf 1 z 2 nz 2
isfinite: nan 1 inf 1 ninf 1 z 1 nz 1
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/