I am trying to understand why using '/' with a long double as follows leads to a value of 0.000000, whereas the same code with double is not
double d = (double)total_results / (double)total_points;
Gives a value of 0.785403, but
long double d = (long double)total_results / (long double)total_points;
Gives the value of 0.000000. I am trying to get the most accurate value for "total_results / total_points"
EDIT: In the end, the error was simply that I output it using "% f" instead of "% Lf"
Before
printf("Running on %d thread(s), results is %f.\n", NUM_THREADS, d);
After
printf("Running on %d thread(s), results is %Lf.\n", NUM_THREADS, d);
Shane source share