Why don't we switch to C like floating pointed arithmetic instead of automatic expansion to reals?

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 4 14:13:23 PDT 2016


On 4 August 2016 at 01:00, Seb via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> Consider the following program, it fails on 32-bit :/
>

It would be nice if explicit casts were honoured by CTFE here.
toDouble(a + b) just seems to be avoiding the why CTFE ignores the
cast in cast(double)(a + b).

> To make matters worse std.math yields different results than
> compiler/assembly intrinsics - note that in this example import std.math.pow
> adds about 1K instructions to the output assembler, whereas llvm_powf boils
> down to the assembly powf. Of course the performance of powf is a lot
> better, I measured [3] that e.g. std.math.pow takes ~1.5x as long for both
> LDC and DMD. Of course if you need to run this very often, this cost isn't
> acceptable.
>

This could be something specific to your architecture.  I get the same
result on from all versions of powf, and from GCC builtins too,
regardless of optimization tunings.


More information about the Digitalmars-d mailing list