piclist 2001\05\31\163350a >
www.piclist.com/techref/index.htm?key=brain+burp+rounding
BY : Paul Hutchinson email (remove spam text)

>This is what I would expect. The numbers x.5 are
>all on the TOP half of the decimal spread, so of
>course the average or total of them will be greater
>than the half way mark. 0.00 to 0.49 is in the first
>half, 0.50 to 0.99 is in the second half.
>Just like 0 to 127 is the first half and 128 to 255
>is the second half in binary.
>
>Where you might be confused is that 0.50 is not
>the half way point between 0 and 1. The half way
>point is AFTER 0.4999999 and BEFORE 0.5.
>So 0.5 is past the half way mark.

Absolutely not true!

I think I see where the confusion is occurring. You are talking about
numbers limited to ranges of 2^x-1 (computer representations of numbers). In
the first paragraph you are talking about a range of 0.00 -> 0.99 (not
1.00).
In the second paragraph you change the range to 0 -> 1 but don't take into
account the change.

The mid way point of any range of numbers is exactly equal to:
(highest value - lowest value) / 2 + lowest value.

For the normal one byte range (0->255) this is:
(255 - 0) / 2 + 0 = 127.5

For the range of 0.00->0.99 it's:
(0.99 - 0.00) / 2 + 0.00 = 0.495

For the range of 0->1 it's:
(1 - 0) / 2 + 0 = 0.5

Here's all the possible 1 decimal place numbers in the range of 0 to 1.
They are: 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 and, 1.0.

There are 11 values and 0.5 is exactly the half way point of a 0 to 1
sequence. There are five numbers above and, five numbers below the mid way
point.

Paul

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestmitvma.mit.edu

<NEBBIAPOKDMDBDIDBPJPOEKPDIAA.phutchinson@imtra.com> 7bit