Talk:Rounding

From Wikipedia, the free encyclopedia

This page is basically redundant with Significant figures#Rounding, but I feel that this is better written, so warrants merging instead of deleting. ~ Irrel 17:33, 28 September 2005 (UTC)

Please restrain yourself. They are very different subjects. And this page doesn't describe rounding very well. --Cat5nap 05:46, 3 October 2005 (UTC)
The discussion at Talk:Significant figures#Merge is overwhelmingly against the suggested merge of Rounding with Significant figures. I suggest the tags be removed. If anything, I'd consider merging with Truncation. Jimp 13Oct05
  • Well, this got resolved pretty much as I intended (altho the merge went the other way). Regardless, I hardly think putting up a "merge?" template shows a lack of restraint, seeing as it's just a request for input. Actually doing the merge, with no discussion -- now that'd be un-restrained. ~ Irrel 20:20, 13 May 2006 (UTC)

"but if the five is succeeded by nothing, odd last reportable digits are decreased by one" Shouldn't this be increased?68.227.80.79 05:44, 13 November 2005 (UTC)

Yes. Thanks for spotting this! -- Jitse Niesen (talk) 12:21, 13 November 2005 (UTC)

Contents

[edit] Rounding negative numbers.

How are negative numbers handled? According to the article round(-1.5) = -2, which is wrong, right? round(-1.5) = -1 I believe.

There are many different implementations. — Omegatron 19:59, 30 June 2006 (UTC)
There are many implementations, and very few are covered in this article. Here's an external article which covers the field [1]. Hopefully someone has time to incorporate the information from that article without engaging in copyvio. -Harmil 15:55, 14 July 2006 (UTC)

[edit] Organization

I don't know if it's a good idea to merge with floor function, but they are related. A sort of "family tree" of rounding functions:

  • Floor
  • Ceiling
  • Half round
    • Half round up
      • Where up is +∞
      • Where up is away from zero
    • Half round down
      • Where down is −∞
      • Where down is towards zero
    • Half round even
    • Half round odd

[edit] Rounding of VAT

The VAT Guide cited states:

Note: The concession in this paragraph to round down amounts of VAT is designed for invoice traders and applies only where the VAT charged to customers and the VAT paid to Customs and Excise is the same. As a general rule, the concession to round down is not appropriate to retailers, who should see paragraph 17.6.

and paragraph 17.6 says the rounding down only is not allowed. So I don't think it is "quite clearly" stated. --81.178.31.210 17:27, 2 September 2006 (UTC)

[edit] Which method introduces the most error?

From the "Round-to-even method" section in this article, as of right now:

"When dealing with large sets of scientific or statistical data, where trends are important, traditional rounding on average biases the data upwards slightly. Over a large set of data, or when many subsequent rounding operations are performed as in digital signal processing, the round-to-even rule tends to reduce the total rounding error, with (on average) an equal portion of numbers rounding up as rounding down."

Huh? Doesn't traditional rounding have an equal portion of numbers rounding up and down? In traditional rounding, numbers between 0 and <5 are rounded to 0, while numbers between 5 and <10 are rounded to 10, if 10 is an increase in the next highest digit of the number being rounded. The difference of (<10 - 5) equals the difference of (<5 - 0), doesn't it? Am I missing something? 4.242.147.47 21:13, 19 September 2006 (UTC)

In four cases (1, 2, 3 and 4) the value is rounded down. In five cases (5,6,7,8,9) the value is rounded up. In one case (0) the value is left unchanged. This may be what you were missing. 194.109.22.149 15:14, 28 September 2006 (UTC)

But "unchanged" is not entirely correct, as there may be further digits after the 0. For example, rounded to one decimal place, 2.304 would round to 2.3; it is not unchanged under the traditional rounding scheme, but rather rounded down, thus making five cases for rounding down and five for rounding up.

If we consider rounding all of 0.00, 0.01, ..., 1.00 (101 numbers) to the nearest one, we get 50 0s and 51 1s. The total amount of down-rounding is -0.01+-0.02+...=\sum_{i=1}^{49} -i/100=-12.25, but the amount of up-rounding is 0.50+0.49+...=\sum_{i=1}^{50} i/100=12.75. The average error is thus \frac{-12.25+12.75}{101}=0.0049505. Importantly, this imbalance remains even if we exclude 1 (where you get 50 numbers going each way), and the average error increases (to precisely half the last digit specified; this is not a coincidence). This is the bias; because it doesn't depend on the granularity of the rounding but rather of the data, it's easy to miss. --Tardis 07:10, 31 October 2006 (UTC)
The number 1.00 should not appear in this calculation. We're interested in rounding the interval [0.00, 1.00) -- that is, all numbers >= 0.00 and < 1.00 (strictly smaller than 1). Once the number 1.00 is removed from the above paragraph, the imbalance disappears (contrary to what's written above). In reality, there is no imbalance in the regular rounding - the interval [0, 0.5) has the same length as the interval [0.5, 1).
But, like 1.00, 0.00 is also not rounded. So the intervals would be (0, 0.5) and [0.5, 1) ; this results in a bias upwards. —The preceding unsigned comment was added by 85.144.113.76 (talk) 00:06, 20 January 2007 (UTC).
If you look at the calculation a bit more closely, you'll see it sums the difference between the number to be rounded and the result of the rounding. In both the 0.00 and 1.00 cases this is 0, so it doesn't matter if you include them in the summation or not.
Tardis said: "This is the bias; because it doesn't depend on the granularity of the rounding but rather of the data, it's easy to miss." This is the crucial point. If the data is quantised (granular) then the error is related to the size of the quantisation. But for any physical process the numbers involved are normally not quantised hence there is no bias at all. If you repeat the calculation above with a rounding granularity of 0.1 still but a data granularity of 0.0001 (say) then you will see this in action. Thus, the conclusion is that if the data set you are rounding has no quantisation, you should use "0.5 goes up" rounding not bankers rounding. 137.222.40.78 (talk) 13:18, 23 May 2008 (UTC)

[edit] Another Method ?

There seems to be at least one other method; rounding up or down with probability given by nearness.

It is given in javascript by
R = Math.round(X + Math.random() - 0.5)

It has the possible advantage that the average value of R for a large set of roundings of constant X is X itself.

82.163.24.100 11:51, 29 January 2007 (UTC)

[edit] Why are halfway-values rounded away from zero?

Can somebody please tell me, why is it - and why does it make sense - that we round, say, 1.5 to 2 and not to 1? Here's my thinking: 1.1, 1.2, 1.3 and 1.4 go to 1 - 1.6, 1.7, 1.8, 1.9 go to 2. So 1.5 is of course right in the middle. Why should we presume it's more 2ish than 1ish, if it's equally close? Do you think it's just because teachers are nice, and when they do grade averages, they want to give you a little boost, rather than cut you down? Is there some philosophical or mathematical justification? Wikidea 23:38, 6 February 2008 (UTC)


You forgot 1.0. —Preceding unsigned comment added by 207.245.46.103 (talk) 19:08, 7 February 2008 (UTC)

I also left out 2.0, surely? Wikidea 19:41, 7 February 2008 (UTC)
I do not see a good reason. A convention is useful, but it could have been the other way around.--Patrick (talk) 23:46, 7 February 2008 (UTC)
That's exactly what I'm thinking too! So maybe it's true: Maths teachers were just being nice in marking up students' average test results! They could've had the convention the other way indeed. Wikidea 00:01, 8 February 2008 (UTC)
Or vendors invented it for finding the price of half a unit. But it is more likely that they round up all broken values, not only those halfway.--Patrick (talk) 00:22, 8 February 2008 (UTC)

Refer to the discussion above, the "Which method introduces the most error?" question. I guess I retract my 1.0 statement. —Preceding unsigned comment added by 207.245.46.103 (talk) 18:30, 8 February 2008 (UTC)