Skip to content
Prev 75866 / 398502 Next

0/0, R segfaults

To expand on Dirk's answer, R relies on fairly close compliance to 
IEC60559 (aka IEEE754) arithmetic in which 0/0 = NaN.  As R is C/Fortran 
program, this is a function of your C/Fortran compilers (it is most likely 
an FPU setting controlled by the compiler than libc).  Problems in this 
area are documented in the R-admin manual.

We don't know the CPU here, so ix86 is a plausible guess.  That has a FPU
control word that determines if 0/0 is NaN or an exception.  Prior to 
glibc 2.1 it could be set by __setfpucw and R sets it if NEED___SETFPUCW
is defined (only in older Linuxen).

Other people using Gentoo are not reporting problems, so this has to be a 
very specific problem, one which is best addressed to a Gentoo list.  Try 
a very simple C program such as

#include <stdio.h>
int main()
{
    double x = 0.0;
    printf("x/x = %f\n", x/x); 
}

R is doing nothing different on my Linux box (except it arranges to print 
NaN not nan regardless of platform).
On Thu, 18 Aug 2005, Dirk Eddelbuettel wrote: