It seems that sprintf doesn't always round up if a value is halfway between two integers:
sprintf('%4.1f', 0.95) ; % Returns 0.9
But it also seems to disobey the IEEE standard of "round toward the even number", though I could be misunderstanding. Left column is the input to the sprintf statement above and right column is the output.
-0.95 -1.0-0.85 -0.8-0.75 -0.8-0.65 -0.7-0.55 -0.6-0.45 -0.5-0.35 -0.4-0.25 -0.3-0.15 -0.1-0.05 -0.10.05 0.10.15 0.10.25 0.30.35 0.40.45 0.50.55 0.60.65 0.70.75 0.80.85 0.80.95 1.0
[Note that roundsd.m enforces the "rounding up" of trailing decimals which can then be fed into sprintf. http://www.mathworks.com/matlabcentral/fileexchange/26212-round-with-significant-digits]
Best Answer