On Thu, 6 Feb 2014, Donovan Watteau wrote:
> David Coppa wrote:
> > Take the following reduced test-case, adapted from what R's code
> > does:
> > 
> > ---8<---
> > 
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <math.h>
> > 
> > int main(void) {
> >     double theta = 1;
> >     long double lambda, pr, pr2;
> > 
> >     lambda = (0.5*theta);
> >     pr = exp(-lambda);
> >     pr2 = expl(-lambda);
> > 
> >     printf("theta == %g, pr == %Lg, pr2 == %Lg\n", theta, pr, pr2);
> >     exit(0);
> > }
> > 
> > ---8<---
> > 
> > This produces the following output on Linux (x86_64):
> > 
> > theta == 1, pr == 0.606531, pr2 == 0.606531
> > 
> > While on OpenBSD -current amd64:
> > 
> > theta == 1, pr == 0.606531, pr2 == nan
> 
> FWIW, it looks even stranger on loongson:
> 
> $ cc -o expl expl.c -O2 -pipe -lm
> $ ./expl
> theta == 1, pr == -9.15569e-2474, pr2 == 6.10667e-4944
> $ ./expl
> theta == 1, pr == 0.606531, pr2 == 0.606531
> $ ./expl
> theta == 1, pr == -9.15569e-2474, pr2 == 6.10667e-4944
> 
> $ sysctl kern.version
> kern.version=OpenBSD 5.5-beta (GENERIC) #106: Mon Feb  3 01:47:15 MST 2014
>     t...@loongson.openbsd.org:/usr/src/sys/arch/loongson/compile/GENERIC

A fix has been committed, but there's still a problem on loongson with
libm updated:

$ ls -l /usr/lib/libm.so.*
-r--r--r--  1 root  bin  926033 Feb 12 12:17 /usr/lib/libm.so.9.0
$ cc -o expl expl.c -O2 -pipe -lm
$ for in in 1 2 3 4 5 6 ; do ./expl ; done
theta == 1, pr == -9.15569e-2474, pr2 == 6.10667e-4944
theta == 1, pr == 0.606531, pr2 == 0.606531
theta == 1, pr == 0.606531, pr2 == 0.606531
theta == 1, pr == 0.606531, pr2 == 0.606531
theta == 1, pr == -9.15569e-2474, pr2 == 6.10667e-4944
theta == 1, pr == 0.606531, pr2 == 0.606531

Reply via email to