Why do inconsistencies exist with floating-point numbers rounding in sprintf, fprintf, sin etc?
Show older comments
Why do inconsistencies exist with floating-point numbers rounding in sprintf, fprintf, sin etc?
str1 = sprintf('%0.1f ',40.05);
str2 = sprintf('%0.1f ',20.05);
str3 = sprintf('%0.1f ',30.05);
str4 = sprintf('%0.1f ',50.05);
disp([str1 ' ' str2 ' ' str3 ' ' str4]);
The output is:
40.0 20.1 30.1 50.0
Accepted Answer
More Answers (0)
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!