Hi,
I have this piece of code in a C program where I trying to convert a double to a long long:
I am not sure what I should do to make the thing working ie avoid this peculiar round off error. Please suggest something.
Thanks.
I have this piece of code in a C program where I trying to convert a double to a long long:
Code:
double x = 0.507462687; double a = pow(10,k+j); double b = pow(10,k); double c = a*x; double d = (long long) (b*x); long long num,denum; num = (long long) (c-d); // the value of num becomes = ........418 instead of ....419 ie the last digit 9 becomes 8.
Thanks.
Comment