Skip to content
Prev 45444 / 63421 Next

double in summary.c : isum

On 24/03/2013 15:01, Duncan Murdoch wrote:
Actually, you don't know.  Really only on almost all Intel ix86: most 
other current CPUs do not have it in hardware.  C99/C11 require long 
double, but does not require the accuracy that you are thinking of and 
it can be implemented in software.

Note that even on ix86 this is something that can be switched on or off 
in the CPU: last time I looked (years ago) it was off by default in 
Microsoft compilers.

All C99 requires is that long double is at least as precise as double. 
C11 recommends in ?F.2

Recommended practice
2 The long double type should match an IEC 60559 extended format.

Notice the 'an': there are two such formats, and both are in use on R 
platforms.  But then some OS/compiler suppliers have never paid any heed 
to ISO standards.
But as I said lower down, a 64-bit integer accumulator would be helpful, 
C99/C11 requires one at least that large and it is implemented in 
hardware on all known R platforms.  So there is a way to do this pretty 
consistently across platforms.