Casting double to ulong weirdness

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 24 14:28:49 PDT 2015


On 8/24/15 5:03 PM, Steven Schveighoffer wrote:
>> Whatever the issue is, it is not unavoidable, because as has been shown,
>> other languages do it correctly.
>
> Your other examples use doubles, not reals. It's not apples to apples.

#include <stdio.h>

int main()
{
     long double x = 1.2;
     x *= 10.0;
     printf("%lld\n", (unsigned long long)x);
}

output:
11

-Steve


More information about the Digitalmars-d mailing list