From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: floating point control settings
Date: Wed, 29 Sep 2010 02:22:06 +0000 (UTC)
Organization: Robust Analysis Inc
Lines: 8
Message-ID: <i7u7se$c4d$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1285726926 12429 (29 Sep 2010 02:22:06 GMT)
NNTP-Posting-Date: Wed, 29 Sep 2010 02:22:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 122612
Xref: comp.soft-sys.matlab:674060

I have a complicated numerical procedure written in C that has been compiled into a library.   When I call one function from a short, standalone C program, I get one answer.  When I call the same compiled code from matlab (through a mex interface), I get a slightly different answer.   The difference is very small, out in the last digit of accuracy, but it causes a later problem that is serious.  (I have to take the result of this calculation and plug it into a function with restricted domain; the slight inaccuracy causes that function to blow up, e.g. sqrt(-1.0e-14).)

I've spent several hours working on this, and the only guess  have as to what is causing this is that matlab sets the floating point control word differently from the standalone program, and this setting makes operations round slightly differently. 

(1)  Does anyone know how matlab sets the FP control word?
(2)  is there any way to find the value of the control word from matlab?
(3) is there any way to find the value of the control word from within C.  I am using MinGW, so gcc compiler on Windows.