The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » sci.math.* » sci.math.num-analysis

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: forcing intel floating registers to use 64-bit arithmetic
Replies: 5   Last Post: Feb 3, 2013 10:48 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
James H. Cloos Jr.

Posts: 4
Registered: 12/12/04
Re: forcing intel floating registers to use 64-bit arithmetic
Posted: Jan 16, 2013 5:33 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

>>>>> "TS" == Tom Stockfisch <> writes:

TS> I need to force all double precision calculations to proceed
TS> strictly in 64-bit -- no 80-bit

The easiest way is to use sse math, which is the default when compiling
for 64 bit mode.

To force the x87 calculations to be done in 64bits, you need to edit the
x87 fp control word. Bits 8 and 9 (the PC field) control precision.

The (binary) value 11 is the default and uses 80 bits.
Value 10 specifies 64 bits.
Value 00 specifies 32 bits.

So you want to clear bit 8 (aka store original and (not 0x100)).

The FLDCW, FRSTOR and FXRSTOR instructions load the control word from
memory; the FSTCW, FNSTCW, FSAVE, FNSAVE and FXSAVE store the word to
memory and the FINIT initializes it to the default value.

The docs say that PC only affects FADDx, FSUBx, FMULx, FDIVx and FSQRT,
so it probably will not guarantee the same results you get from sse math
or other processors.

In the end it is almost always simpler and better to forget the legacy
x86 mode entirely and only use the x86_64 mode.

James Cloos <> OpenPGP: 1024D/ED7DAEA6

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.