The tricky point with the round-half-up algorithm arrives when we come to consider negative numbers. In the case of the values –3.1, –3.2, –3.3 and –3.4, these will all round to the nearest integer, which is –3; similarly, in the case of values like –3.6, –3.7, –3.8 and –3.9, these will all round to –4. The problem arises in the case of –3.5 and our definition as to what "up" means in the context of "round-half-up." Based on the fact that a value of 3.5 rounds up to 4, most of us would intuitively expect a value of –3.5 to round to –4. In this case, we would say that our algorithm was symmetric for positive and negative values.
However, some applications (and mathematicians) regard "up" as referring to positive infinity. Based on this, –3.5 will actually round to –3, in which case we would class this as being an asymmetric implementation of the round-half-up algorithm. For example, the round method of the Java Math Library provides an asymmetric implementation of the round-half-up algorithm, while the round function in Matlab provides a symmetric implementation. Just to keep us on our toes, the round function in Visual Basic for Applications 6.0 actually implements the round-half-even (banker's rounding) algorithm discussed below.
Round-half-down: This acts in the opposite manner to its round-half-up counterpart. In this case, a halfway value such as 3.5 will round to 4. Once again, we run into a problem when we come to consider negative numbers, depending on what we assume "down" to mean. In the case of a symmetric implementation of the algorithm, a value of –3.5 will round to –3. By comparison, in the case of an asymmetric implementation of the algorithm, in which "down" is understood to refer to negative infinity, a value of –3.5 will actually round to –4.
As a point of interest, the symmetric versions of rounding algorithms are sometimes referred to as Gaussian implementations. This is because the theoretical frequency distribution known as a Gaussian distribution--which is named for the German mathematician and astronomer Karl Friedrich Gauss (1777-1855)--is symmetrical about its mean value.
Round-half-even: If halfway values are always rounded in the same direction (for example 3.5 rounds to 4 and 4.5 rounds to 5), the result can be a bias that grows as more rounding operations are performed. One solution toward minimizing this bias is to sometimes round up and sometimes round down.
In the case of the round-half-even algorithm (which is often referred to as "banker's rounding" because it is commonly used in financial calculations), halfway values are rounded toward the nearest even number. Thus, 3.5 will round up to 4 and 4.5 will round down to 4. The round-half-even algorithm is, by definition, symmetric for positive and negative values, so both –3.5 and –4.5 will round to –4.
Round-half-odd: This is the theoretical counterpart to the round-half-even algorithm, in which halfway values are rounded toward the nearest odd number. In this case, 3.5 will round to 3 and 4.5 will round to 5 (similarly, –3.5 will round to –3 and –4.5 will round to –5). In practice, however, the round-half-odd algorithm is never used because it will never round to zero (rounding to zero is often a desirable attribute for rounding algorithms).