<p>I can reset FPU's CTRL registers with this:</p>

<p><a href="http://support.microsoft.com/kb/326219" rel="nofollow noreferrer">http://support.microsoft.com/kb/326219</a></p>

<p>But how can I save current registers, and restore them later?</p>

<p>It's from .net code..</p>

<p>What I'm doing, is from Delphi calling an .net dll as an COM module. Checking the <kbd>Ctrl</kbd> registers in delphi yield one value, checking with controlfp in the .net code gives another value. 
What I need, is in essential is to do this:</p>

<pre><code>_controlfp(_CW_DEFAULT, 0xfffff); 
</code></pre>

<p>So my floatingpoint calculations in the .net code does not crash, but I want to restore the <kbd>Ctrl</kbd> registers when returning.</p>

<p>Maybe I don't? Maybe Delphi is resetting them when needed?
I blogged about this problem <a href="http://blog.neslekkim.net/2008/10/fpu-issues-when-interoping-delphi-and.html" rel="nofollow noreferrer">here</a>.</p>

Same function you use to change them:
```
_controlfp()
```
. If you pass in a mask of 0, the current value won't be altered, but it
will
be returned - save it, and use a second call to
```
_controlfp()
```
to restore it later.