Precision issue when comparing matlab output with c code output
Ältere Kommentare anzeigen
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 Kommentare
John D'Errico
am 26 Mär. 2025
Bearbeitet: John D'Errico
am 26 Mär. 2025
"My results are matching up to 18th decimal points."
Then what is the problem, since that is beyond the limit of double precision?
Anyway, you say you are observing a difference someplace, on some unspecified computation. But we cannot see inside your computer, to actually know what you did. If you like, we can try using the MATLAB crystal ball, but it is always foggy these days. I think I dropped mine on the floor too many times. But the MATLAB tarot cards are an option too if that fails.
OR, you can actually show us what you did, instead of a vague description of something that does not match up. Is there a good reason why you want to make it impossible for anyone to help you? Make it easy to get help.
dpb
am 26 Mär. 2025
This may boil down to one of the issues in <the last thread on similar comparison>, comparing output values with inconsistent formatting/precision.
Although note @Vaishnavi that the i/o formatting routines will continue outputting characters ad infinitum, long past the actual internal precision of the data storage size limits.
James Tursa
am 26 Mär. 2025
@Vaishnavi Please post a small complete example that demonstrates your problem.
Walter Roberson
am 26 Mär. 2025
Also, it is potentially possible differences are due to the rounding mode in effect.
dpb
am 26 Mär. 2025
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?
"18 decimal points" is not necessary the same as 18 digits of precision. For example,
A = 0.0000000000123456789478;
fprintf('%.19f\n', A)
might seem to be valid to 19 decimal places, if you count starting from the period.
Antworten (0)
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!