When rounding numbers (for example, rounding a real number to the nearest integer), the "round to nearest" rule is usually used. For example, 1.4 is rounded down to 1 and 1.6 is rounded up to 2.
However, some sort of tie-breaking rule is needed in the case of a real number exactly halfway between two integers, such as 2.5 or 3.5. There are several such tie-breaking rules; here are two possibilities:
When I was in elementary school in the United States in the 1990s, the rule taught was to round up in the case of a tie. So, 2.5 is rounded up to 3 and 3.5 is rounded up to 4. Wikipedia calls this the "round half up" tie-breaking rule. This method introduces a "toward-infinity" bias, since 0.5 is always rounded up. I guess we were taught this way because that was before we were taught about even and odd integers?
Another (perhaps better) possibility is the "round half to even" tie-breaking rule, where the halfway value is rounded to the nearest even integer. So, 2.5 is rounded to 2 and 3.5 is rounded to 4. This method does not have the overall "toward-infinity" bias that method (1) has, but it does introduce a "toward-zero" bias for even numbers, and a "toward-infinity" bias for odd numbers. Wikipedia says that this method is the default method in IEEE 754 floating point functions, so apparently this is a well-established method.
Of course, there are still other possibilities, like "round half to odd" and so on, but for now, let's just consider methods (1) and (2).
My original question was, which method does Mathematica use? I did the following test using NumberForm and Round:
list1 = {2.5, 3.5}; NumberForm[#, {Infinity, 0}] & /@ list1 Round[#] & /@ list1 which gives this output:
{3., 4.} {2, 4}
so it seems that NumberForm uses method (1) whereas Round uses method (2). Is this a correct assessment?
The Mathematica (version 8) documentation for NumberForm does not seem to comment on this, as far as I can tell. On the other hand, the Mathematica (version 8) documentation for Round says, "Round rounds numbers of the form x.5 toward the nearest even integer."
Based on this, my question is, why do NumberForm and Round apparently use different tie-breaking methods? (I suppose that there may not be an answer to this question, since perhaps it is just "what it is.")
Moreover, are NumberForm and Round different in other ways? For one thing, NumberForm acts as a wrapper and thus only affects printing, not evaluation, whereas Round affects evaluation. But, besides this, are there other fundamental differences between NumberForm and Round in Mathematica 8?
NumberFormisn't used in further calculations, it doesn't matter. As of the difference, I guess they were implemented by different people. It makes sense thatRoundwould be implemented by someone with a solid numeric programming background, while a presentation function would possibly be implemented by someone without special numerics knowledge (but maybe more knowledge about presentation issues), who just implemented the rule he learned in school. $\endgroup$