Skip to main content
7-Bedrock
October 19, 2010
Question

Numbers approximation

  • October 19, 2010
  • 5 replies
  • 16039 views

My dilemma has arisen from a debate with my 9.5 years old daughter about her school teacher taught her during classes.

So my daughter told me that by convention (if someone has to) he/she may approximate 15 by 20 (two tens), 9.5 (b t w ! ) to 10, and so on.

Personally I didn't care much for long time of such kind of approximation, but I answered her that it seemed to me quite strange.

Then we turned to Mathcad and we got the results in the attached sample.

All seems in line with my daughter's teacher, excepting the last (fifth) example, where unlike the first four cases, round estimate is made by diminution ...,
that is 987654325 is rounded to 9.8765432*10^8.

So, why the different behiavour in the last case ? Exception is determined by the conversion of the number into binary (or hexadecimal) numbers made internally by computer in this particular case .... ?

(Actually, by accident the first example I gave to my daughter was the exception of the fifth number).

In the first four examples, is really a matter of accepted convention for making up the round approximate ?

(As shown, same result in older version of Mathcad like Mcd2001).

Best regards, Liv.

5 replies

1-Visitor
October 19, 2010

An obscure bug, affecting only 2nd, 7th, and 11th decimal places:

rounding bug.gif

TTFN

1-Visitor
October 19, 2010
1-Visitor
October 19, 2010

Interestingly, Studyworks does not have the same problem with the 2nd decimal place, but does have the 7th and 11th decimal place error:

rounding bug SW.gif

TTFN

19-Tanzanite
October 20, 2010
So, why the different behiavour in the last case ? Exception is determined by the conversion of the number into binary (or hexadecimal) numbers made internally by computer in this particular case .... ?

Yes, I think so. I'm not sure if I would even classify this as a bug. It's just a reality of numerical computing. The symbolic processor can do arbitrary precision arithmetic, and therefore doesn't show the problem

1-Visitor
October 20, 2010

Yes, I think so. I'm not sure if I would even classify this as a bug. It's just a reality of numerical computing. The symbolic processor can do arbitrary precision arithmetic, and therefore doesn't show the problem

I would violently disagree. The algorithm does not require extreme precision, since it's quite capable of converting from the IEEE binary format to decimal and displaying the result. Based on the displayed result, there is absolutely no ambiguity about how it should round. The fact that it can correctly round 99.999999% of the time shows that it's not at all random, and is in fact, quite deterministic. Excel doesn't have this problem with its rounding function; I can't accept that the SW guys at MS are that much better at this than the Radzow and guys at Mathsoft.

TTFN

Liv7-BedrockAuthor
7-Bedrock
October 21, 2010

I tend to agree with Mei ....

Using keyword "float" (symbolic calculation), one may get some others examples of unusual ('unconventional') results

(I wonder how many... see attached).

In other software, it seems to appear similar unusual display, but there it is less important since underlying number is kept as in the original format.

However, it thus becomes more captivating to assist my daughter for her homeworks.

I must do it more often.

And, if I have the choice, I'll try to negotiate my next bank loan for a 9.825 % interest (thanks to Mei, too).

Best regards,

Liv.

Liv7-BedrockAuthor
7-Bedrock
October 21, 2010

I agree with you, Richard, but for a humble user it's quite tricky ...

Best, Liv.

Liv7-BedrockAuthor
7-Bedrock
October 21, 2010

Oh, I forget ...

Some part of my dilemma is still there.

So I was curious if it's matter of general accepted convention for computers to round up numbers with 5 last digit ..., or, if not,

is there some other special reason for rounding up ?

(It's true that some of the first computing machines were made for banking to calculate debts interests ...

Many thanks, Liv.

1-Visitor
October 21, 2010

What is learned in school, around 5th grade or so, is to round up on 5.

However, there is a school of thought that 5 is exactly halfway and shouldn't be arbittrarily rounded up, as that would introduce a statistical bias, so one approach is to round up if the preceeding digit is odd, and round down if the preceeding digit is even.

For a more detailed and laborious discussion, see:

http://en.wikipedia.org/wiki/Rounding

and:

http://en.wikipedia.org/wiki/Round-off_error

TTFN

1-Visitor
October 21, 2010

Specific to the question about computers, they tend to truncate or round up, depending on how the hardware is implemented. On a fixed-precision calculation, the result would most likely be truncated. But if the calculation is done at a higher precision, and displayed or transferred at a lower precision, then the implementers may elect to round up.

In general, the question would be pretty much moot, since most computers implement the equivalent of about 16 digits of decimal precision, and the rounding only occurs in the last digit, and only obscure, or badly formed, calculations would exercise the last digit to the point of significance.

TTFN

Liv7-BedrockAuthor
7-Bedrock
October 24, 2010

Starting from your observation, Richard, i. e. numbers ending in 5 with irrational binary, one can find all numbers between 0 and let's say 10^6
for which I bet MCD (14) rounding is failing or contradictory (see also attached).

And I agree with you that "a bit better" may be the way to remedy...

As a 'fan' of Mathcad, looking for a better product, I've already mentioned, Mei, the rounding bug under Discussion
"What new features [...] in MCD Prime?"

Best, Liv.

1-Visitor
October 25, 2010

All very interesting, but somewhat irrelevant, since Excel does not have this problem. This problem is unique to Mathcad.

Since the underlying math hardware is the same, the difference is how the hardware is used.

Now, it may be possible that Excel has other bugs, but at least in this case, it does not have the problem that Mathcad has.

TTFN