Skip to content
Prev 37694 / 63421 Next

Non identical numerical results from R code vs C/C++ code?

On Fri, 10 Sep 2010, Duncan Murdoch wrote:

            
As a little more detail, 'long double' is in the C99 standard and seems to be fairly widely implemented, so code using it is likely to compile.   The Standard, as usual, doesn't define exactly what type it is, and permits it to be a synonym for 'double', so you may not get any extra precision.

On Intel chips it is likely to be the 80-bit type, but the Sparc architecture doesn't have any larger hardware type.  Radford Neal has recently reported much slower results on Solaris with long double, consistent with Wikipedia's statement that long double is sometimes a software-implemented 128-bit type on these systems.
Thomas Lumley
Professor of Biostatistics
University of Washington, Seattle