Casting double to ulong weirdness

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 25 16:04:33 PDT 2015


On Tuesday, 25 August 2015 at 21:21:59 UTC, Matthias Bentrup 
wrote:
> On Tuesday, 25 August 2015 at 15:19:41 UTC, Márcio Martins 
> wrote:
>>
>> If you compile it with *GDC* it works fine. If you compile a 
>> port with clang, gcc or msvc, it works right as well. I 
>> suspect it will also work fine with LDC.
>
> The same program "fails" in gcc too, if you use x87 math. 
> Usually C compilers allow excess precision for intermediate 
> results, because the extra precision seldom hurts and changing 
> precision on x87 is very expensive (depends on the CPU, but it 
> is more expensive than the trigonometric functions on some 
> models).

That's because of floating point exception. It is very 
constraining for the hardware.


More information about the Digitalmars-d mailing list