This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Problem with zeros.
Hi,
Éric Depagne wrote:
>> Actually, I do get the subnormals on FreeBSD. Perhaps, this
>> is a glibc bug.
>>
> If it is a bug in the glibc, would a program written in C show the same
> behaviour?
>
> I don't know anything about C but this would be an easy way to test this,
> isn't it?
>
Well, a C program would be something like:
-----------------------------------
#include <stdio.h>
void test(const char *a)
{
float f;
sscanf(a,"%e", &f);
printf("%s = %e\n", a, (double) f);
}
int main()
{
test("1.1754944e-38");
test("1.1754944e-39");
test("1.1754944e-40");
test("1.1754944e-41");
test("1.1754944e-42");
test("1.1754944e-44");
test("1.1754944e-45");
test("1.1754944e-46");
test("1.1754944e-47");
return 0;
}
-----------------------------------
Which gives here (GLIBC 3.6, x86-64 on openSUSE):
1.1754944e-38 = 1.175494e-38
1.1754944e-39 = 1.175495e-39
1.1754944e-40 = 1.175493e-40
1.1754944e-41 = 1.175549e-41
1.1754944e-42 = 1.175689e-42
1.1754944e-44 = 1.121039e-44
1.1754944e-45 = 1.401298e-45
1.1754944e-46 = 0.000000e+00
1.1754944e-47 = 0.000000e+00
Thus denormal numbers are supported, but 9.999e-46 is rounded down to
zero and not up to 1.401298e-45, which I think is fine and not a bug.
Tobias