Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#367 fpclassify/isnormal can't detect denormalised floating point numbers

v1.0 (example)
open-accepted
nobody
None
5
2013-12-02
2013-12-01
Peter Bex
No

A simple program which prints the value of isnormal(4.9406564584124654417657e-324) shows 1 (also if that value is assigned to a variable declared "double" and that variable is tested):

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

int main(void) {
  double x = 4.9406564584124654417657e-324;
  printf("Normal? %d\n" isnormal(x));
  printf("Normal? %d\n" isnormal(4.9406564584124654417657e-324));
}

The program should show "Normal? 0" twice. The denormalised number has been taken from the ATF tests for fpclassify/isnormal from the NetBSD source tree.

More denormalised numbers from that test suite:

1.1125369292536006915451e-308
-5.5626846462680034577256e-309
4.9406564584124654417657e-324

This has been reported for MingW as well, and hasn't been fixed there yet either: http://sourceforge.net/p/mingw/bugs/1927/

Discussion

  • Kai Tietz
    Kai Tietz
    2013-12-02

    I tested your testcase on linux using glibc (libm), and it produces same result as we do on mingw-w64's trunk.
    In both cases isnormal is 0 (as to be expected).

     
  • Kai Tietz
    Kai Tietz
    2013-12-02

    • status: open --> pending-invalid
     
  • Kai Tietz
    Kai Tietz
    2013-12-02

    IMHO is testcase invalid.

     
  • Kai Tietz
    Kai Tietz
    2013-12-02

    • status: pending-invalid --> open-accepted
     
  • Kai Tietz
    Kai Tietz
    2013-12-02

    So, found the issue. It affects 32-bit only.
    For 32-bits result is 1, for 64-bit result is 0. So the bug seems to be on 32-bit side.