Always false float comparisons

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Mon May 16 12:01:19 PDT 2016


On 16.05.2016 07:49, Max Samukha wrote:
> On Monday, 16 May 2016 at 04:02:54 UTC, Manu wrote:
>
>> extended x = 1.3;
>> x + y;
>>
>> If that code were to CTFE, I expect the CTFE to use extended precision.
>> My point is, CTFE should surely follow the types and language
>> semantics as if it were runtime generated code... It's not reasonable
>> that CTFE has higher precision applied than the same code at runtime.
>> CTFE must give the exact same result as runtime execution of the
>> function.
>>
>
> You are not even guaranteed to get the same result on two different x86
> implementations.

Without reading the x86 specification, I think it is safe to claim that 
you actually are guaranteed to get the same result.

> AMD64:
>
> "The processor produces a floating-point result defined by the IEEE
> standard to be infinitely precise.
> This result may not be representable exactly in the destination format,
> because only a subset of the
> continuum of real numbers finds exact representation in any particular
> floating-point format."
>

This just says that results of computations will need to be rounded to 
fit into constant-size storage.


More information about the Digitalmars-d mailing list