私はなぜ、 '/'を使用して、次の方法でlong doubleを使用すると、0.000000の値になるのか理解しようとしていますが、同じコードはdoubleではありません
double d = (double)total_results/(double)total_points;
0.785403という値を与える
long double d = (long double)total_results/(long double)total_points;
値0.000000を指定します。私は 'total_results/total_points'の最も正確な値を取得しようとしています
編集:最終的にエラーは単に '%Lf'の代わりに '%f'を使用して出力していたということでした
前
printf("Running on %d thread(s), results is %f.\n", NUM_THREADS, d);
後
printf("Running on %d thread(s), results is %Lf.\n", NUM_THREADS, d);