From ripley at stats.ox.ac.uk  Wed Feb 22 13:27:10 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 22 Feb 2006 12:27:10 +0000 (GMT)
Subject: [Rd] Computing means, variances and sums
In-Reply-To: <43FC5500.9010500@stats.uwo.ca>
References: <Pine.LNX.4.64.0602190957290.4741@gannet.stats.ox.ac.uk>
	<43F8C0D1.6000907@pdf.com>
	<f8e6ff050602191142x6a7c1359v768980d0f8842bf2@mail.gmail.com>
	<Pine.LNX.4.64.0602192014300.28769@gannet.stats.ox.ac.uk>
	<43F8E9FF.9080304@stats.uwo.ca>
	<Pine.LNX.4.64.0602220838280.19147@gannet.stats.ox.ac.uk>
	<43FC5500.9010500@stats.uwo.ca>
Message-ID: <Pine.LNX.4.64.0602221217150.30614@gannet.stats.ox.ac.uk>

On Wed, 22 Feb 2006, Duncan Murdoch wrote:

> On 2/22/2006 3:52 AM, Prof Brian Ripley wrote:
>> I've managed to track this down.  The setting of the FPU control word on a 
>> ix86 machine changes the precision of (gcc) long double calculations in the 
>> FPU, as well as those of double.  So if it gets changed to PC_53, long 
>> doubles lose accuracy even though 10 bytes are carried around.
>> 
>> For some discussion of extended-precision issues, see Priest's annex to
>> Goldberg's paper at http://www.validlab.com/goldberg/paper.pdf.
>> 
>> Many other OSes other than Windows on ix86 do consider the FPU control word 
>> when doing context-switching.  There is (often heated) debate as to what 
>> the correct default should be, see e.g. the thread begining
>
> I think Windows also preserves the FPU control word across context switches. 
> The problem is that it doesn't do a context switch when you make a call into 
> the system.  In particular, the shell services (file dialogs, URL 
> recognition, etc.) involve a large number of DLLs, all running within the 
> same context.  MSVC++ normally chooses 53 bit precision as the default, and 
> will set that when a DLL starts up, or whenever a function in it asks to 
> reset the FPU.

Yes, I think you are correct. In that case the difference is that it is 
considered legitimate for a shared resource (a DLL) to change the control 
word in the context that initializes it.

Since as I understand it Win64 does not have a working controlfp nor the 
ability to change precision (from 
http://msdn2.microsoft.com/en-us/library/e9b52ceh.aspx) in its native 
mode, maybe one day this will go away.

Brian Ripley

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Computing means, variances and sums
Prof Brian Ripley