C : erroneous output for "(long long int) = (long long int) * (double)"?

Posted by Rohit on Stack Overflow See other posts from Stack Overflow or by Rohit
Published on 2009-09-12T09:10:36Z Indexed on 2010/03/13 17:55 UTC
Read the original article Hit count: 384

long long int A = 3289168178315264;
long long int B = 1470960727228416;
double D = sqrt(5);

long long int out = A + B*D;

printf("%lld",out);

This gives result : -2147483648

I am not able to figure out why (it should be a positive result). Can somebody help?

© Stack Overflow or respective owner

Related posts about c

    Related posts about double