Precision issue when comparing matlab output with c code output

5 ビュー (過去 30 日間)
Vaishnavi
Vaishnavi 2025 年 3 月 26 日
コメント済み: Walter Roberson 2025 年 3 月 26 日

I am trying to compare my c code output with matlab output. My results are matching up to 18th decimal points. When both matlab and c compiler uses ieee754 floating point format. Then why am I observing the difference. As matlab by default uses double precision, my c code is also using double data type.

  6 件のコメント
dpb
dpb 2025 年 3 月 26 日
If identical past the 15-16 digits of DP, though? That's what makes this one hard to figure...OP says agree precisely to 18 decimal places?
Walter Roberson
Walter Roberson 2025 年 3 月 26 日
"18 decimal points" is not necessary the same as 18 digits of precision. For example,
A = 0.0000000000123456789478;
fprintf('%.19f\n', A)
0.0000000000123456789
might seem to be valid to 19 decimal places, if you count starting from the period.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by