Always false float comparisons

Manu via Digitalmars-d digitalmars-d at puremagic.com
Sun May 15 23:57:52 PDT 2016


On 16 May 2016 at 15:49, Max Samukha via Digitalmars-d
<digitalmars-d at puremagic.com> 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. 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."

I think that is to be interpreted that the result will be the closest
representation possible (rounding up), and that's not fuzzy.
I've never heard of an IEEE float unit that gives different results
than another one...?


More information about the Digitalmars-d mailing list