# NavList:

## A Community Devoted to the Preservation and Practice of Celestial Navigation and Other Methods of Traditional Wayfinding

**Re: Rounding decimal fractions**

**From:**Lu Abel

**Date:**2013 Jul 18, 13:18 -0700

There's "traditional" rounding and "computer" rounding.

The idea in rounding is not to introduce biases or distortion, especially when dealing with a reasonably large quantity of individual numbers. Assuming a randomly scattered set of numbers, if I round down if it's x.4 or less, round up if it's x.6 or more, the resulting sum of the rounded numbers should be the same as (or statistically very close to) the sum of the unrounded numbers.

The problem is with x.5. If I consistently round up, then I will affect the sum of the rounded numbers. So engineers, statisticians, and others dealing with the need to round numbers were taught the "round towards even" rule -- if x were an odd number, you rounded up, if x were an even number, you rounded down. Statistically, that assured that half the time you added 0.5 and half the time you subtracted 0.5, so things came out even.

Then came computers. In the early days when each transistor counted it was too costly to implement a "always round towards even" rule. So computers always rounded x.5 up. Even when transistors became infinitely cheap (today, millions of them are thrown at making a chip run 2% faster) the "always round up" rule was so firmly embedded that nobody changed it.

And what is taught in engineering schools has changed to "always round up." But us oldsters remember the "round towards even" rule...

The idea in rounding is not to introduce biases or distortion, especially when dealing with a reasonably large quantity of individual numbers. Assuming a randomly scattered set of numbers, if I round down if it's x.4 or less, round up if it's x.6 or more, the resulting sum of the rounded numbers should be the same as (or statistically very close to) the sum of the unrounded numbers.

The problem is with x.5. If I consistently round up, then I will affect the sum of the rounded numbers. So engineers, statisticians, and others dealing with the need to round numbers were taught the "round towards even" rule -- if x were an odd number, you rounded up, if x were an even number, you rounded down. Statistically, that assured that half the time you added 0.5 and half the time you subtracted 0.5, so things came out even.

Then came computers. In the early days when each transistor counted it was too costly to implement a "always round towards even" rule. So computers always rounded x.5 up. Even when transistors became infinitely cheap (today, millions of them are thrown at making a chip run 2% faster) the "always round up" rule was so firmly embedded that nobody changed it.

And what is taught in engineering schools has changed to "always round up." But us oldsters remember the "round towards even" rule...

From:Paul Hirose <cfuhb-acdgw@earthlink.net>

To:luabel@ymail.com

Sent:Thursday, July 18, 2013 12:33 PM

Subject:[NavList] Rounding decimal fractions

Stan K wrote: > A couple of years ago a friend of mine and I were discussing how to implement Increments and Corrections in my Celestial Tools program and his Navigation Calculator Workbook spreadsheet. Looking at the output of his spreadsheet, we noticed that the Almanac values apparently did not use what we call "standard" rounding, in this case, for instance, 0.00 through 0.04 would round down to 0.0 and 0.05 through 0.09 would round up to 0.1. I thought the convention, when a decimal can be rounded up or down with equal accuracy, is "round to even." E.g., 1.05 rounded to the nearest tenth is 1.0, but 1.15 is 1.2. But I see that my HP 49G calculator rounds up in these borderline cases. With 2 decimal point precision selected, 1/8 = .13, 3/8 = .38, 5/8 = .63, 7/8 = .88. The composite formatting feature in Microsoft's .NET Framework does the same thing as the calculator. But I discovered the .NET Math.Round class gives the programmer a "round to even" option. Results from a test program: 0.125 0.13 0.12 0.375 0.38 0.38 0.625 0.63 0.62 0.875 0.88 0.88 The first column is the fraction to full accuracy. In the second and third columns I used composite formatting with precision of two decimal places. The difference is that in the third column the value was first rounded with Math.Round. The sum of the second column is a little high (1/8 + 3/8 + 5/8 + 7/8 = 2 exactly) because rounding all borderline cases up introduces a small systematic error. I have to admit I never pay attention to these fine points in my own software. Since Tinyac and Lunar3 both have selectable precision, I assume the user will use, say, .01 precision if "tenths" are critical. -- I filter out messages with attachments or HTML.View and reply to this message: http://fer3.com/arc/m2.aspx?i=124634