std.math performance (SSE vs. real)

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 3 14:01:23 PDT 2014


On Thu, 03 Jul 2014 12:45:17 -0700
Walter Bright via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> On 7/3/2014 3:49 AM, Jonathan M Davis via Digitalmars-d wrote:
> > I don't think that there's anything unclear about that. The problem
> > is that if real is supposed to be the largest hardware supported
> > floating point type, then that doesn't necessarily match long
> > double. It happens to on x86 and x86_64, but it doesn't on other
> > architectures.
>
> As it turns out, C compilers tend to use long double for that. So
> there's no issue. In any case, it's up to the person porting the D
> compiler to that platform to make these decisions.
>
> For another case, D for Win64 maps real to 80 bits, despite VC++
> mapping long double to 64 bits. This is compatible with the D spec,
> because you are still able to call C functions typed as "int foo(long
> double r)" because D's double works for that.
>
> I think that some common sense on a case by case basis for each
> platform should work fine.

I'm fine with real varying from platform to platform depending on what makes
sense for that platform, but I think that it should be clear what real is
generally supposed to be (e.g. the largest floating point type that the
hardware supports), but unless it's _guaranteed_ that real be the same as long
double, I would strongly argue in favor of having an alias for long double
rather than using real directly (much as it will likely be an alias to real in
most cases). We already do that with c_long.

- Jonathan M Davis


More information about the Digitalmars-d mailing list