Casting double to ulong weirdness
Warwick via Digitalmars-d
digitalmars-d at puremagic.com
Tue Aug 25 14:30:02 PDT 2015
On Tuesday, 25 August 2015 at 20:00:11 UTC, bachmeier wrote:
> On Tuesday, 25 August 2015 at 18:15:03 UTC, Ola Fosheim Grøstad
> wrote:
>
> I'm pretty sure Walter has stated the reason that you cannot
> count on exact precision, but I don't remember what it is.
Probably because DMD is spewing out x87 code. The x87 FPU
converts everything to its internal working bit depth before it
does the math op. You can set it to work at different bit depths
but IIRC it's a fairly expensive operation to change the FPU
flags. You really dont want to be doing it every time some mixes
a double and a float.
The compilers that dont exhibit this problem might set the x87 to
work at 64 bit at startup or more likely they are using scalar
SSE. You cant mix different depth operands in SSE. You cant
multiply a float by double for example, you have to convert one
of them so they have the same type. So in SSE the bit depth of
every op is always explicit.
More information about the Digitalmars-d
mailing list