Bug?

deed via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 24 00:48:41 PDT 2014


On Thursday, 23 October 2014 at 21:42:46 UTC, anonymous wrote:
> On Thursday, 23 October 2014 at 21:17:25 UTC, deed wrote:
>> Some testing can be found on http://dpaste.dzfl.pl/5f55f4152aa8
>> for both Windows and Linux. This just illustrates the sin 
>> function.
>
> I think the tests marked "[1]" are expected to fail. They 
> involve
> converting one operand of the comparison to double, but not the
> other. The comparison is done using real precision. So, one
> operand goes through a real->double->real conversion, which
> changes the value.

You're right about those marked [1]; sin returns real and 
shouldn't be expected to equal the same value truncated to double 
or float and then extended back to real.

Converting the sin to double and compare is expected to work for 
those, and it does when compiled with -m64, but not with -m32, on 
Linux:

--
import std.math : sin;
import std.conv : to;
double fun (double a) { return sin(a); }

immutable double a = 3.
assert (fun(a) == sin(a).to!double);  // Works when compiled with 
-m64
--

The behaviour of those only marked [2] and [4] (the 32-bit 
versions) seems to be a bug.


More information about the Digitalmars-d-learn mailing list