 |
|
List Archives > 
Mathcad List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[mathcad] Re: Rounding up/down error
| [mathcad] Re: Rounding up/down error |
|
Author: Chris Whitford
Posted: Tue, 15 Jul 2003 09:04:29 +0100
|
I suspect the reason is this: numbers are represented internally by a
normalised mantissa (52 bits) times a power of 2. Most decimal fractions
cannot be represented exactly, so some rounding takes place. Then when you
display the number, it is converted back to decimal, and it gets rounded
again. The first rounding could take it up or down, by a very tiny amount.
The actual IEEE floating point format specifies that if the number ends in
exactly 0.5, it is rounded to the nearest even integer. So 1.5 and 2.5 are
both rounded to 2. This is so that, statistically, 0.5 is rounded up or
down with equal probablility.
Chris
At 09:12 15/07/2003 +0200, you wrote:
>I have been using a calculation with a number of 0.04425 N/mm^2. However,
>I noticed a strange behavior when I modified the properties of a result to
>show me 4 digits. Normally, it would then show me 0.0443 as a 5 always
>rounds up. However, as you can see in the attached mathcad-sheet, MathCad
>decides that it does not want to show 0.0443, but 0.0442. I have been
>playing with a few other numbers, but this is the only one I have found.
>Can someone tell me, whether this is a bug in MathCad, or that there is an
>option included in MathCad that makes sure that some results are rounded
>to a different value? (Or perhaps someone else has encountered the same
>rounding error somewhere else...)
+------------------------------------------------------------------+
+ Chris Whitford University of Leicester +
+ Research Fellow Space Research Centre +
+ Tel: +44 (0)116 252 3496 Physics and Astronomy Department +
+ Fax: +44 (0)116 252 2464 University Road +
+ email: LEICESTER LE1 7RH +
+ http://www.star.le.ac.uk/ UK +
+------------------------------------------------------------------+
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] RE: Rounding up/down error |
|
Author: Fletcher, Ian
Posted: Wed, 16 Jul 2003 14:56:04 +0100
|
All,
I would regard this result as getting what I had asked for. A calculation
using the result displayed without rounding would use the non-rounded figure
as you would require.
Regards,
Ian Fletcher.
-----Original Message-----
From: Sander Lablans />
Sent: 15 July 2003 08:12
To: Mathcad Discussion List
Subject: [mathcad] Rounding up/down error
[Edit] and now with attachment... [Edit]
Hello list,
I have been using a calculation with a number of 0.04425 N/mm^2. However, I
noticed a strange behavior when I modified the properties of a result to
show me 4 digits. Normally, it would then show me 0.0443 as a 5 always
rounds up. However, as you can see in the attached mathcad-sheet, MathCad
decides that it does not want to show 0.0443, but 0.0442. I have been
playing with a few other numbers, but this is the only one I have found. Can
someone tell me, whether this is a bug in MathCad, or that there is an
option included in MathCad that makes sure that some results are rounded to
a different value? (Or perhaps someone else has encountered the same
rounding error somewhere else...)
Regards,
Sander Lablans
---------------------------------
NedTech Engineering B.V.
The Netherlands
---------------------------------------------------------------------------------------------------------------
The information contained in this message is sent in the strictest confidence for the addressee only. It is intended only for the use of the addressee and may contain legally privileged information. If you have received this e-mail in error you are requested to preserve its confidentiality and advise the sender of the error in transmission.
It is the responsibility of the addressee to scan this email and any attachments for computer viruses or other defects. The sender does not accept liability for any loss or damage of any nature, however caused, which may result directly or indirectly from this email or any file attached.
Talisman Energy (UK) Limited, incorporated in England and Wales (company number 825828) having its registered office at 20-22 Bedford Row, London WC1R 4JS
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] RE: Rounding up/down error |
|
Author: Richard Jackson
Posted: Wed, 16 Jul 2003 10:12:07 -0400
|
Except that it doesn't give you a non-rounded (i.e. truncated) figure. It
gives you either a truncated or a rounded figure, depending on the
number. I agree with those that view this as a problem that should get
fixed. I would prefer that it displays a rounded number, but I could live
with a truncated one. Maybe. A mixture of the two is not acceptable
though.
Richard
On 16 Jul 2003 at 14:56, Fletcher, Ian wrote:
> All,
>
> I would regard this result as getting what I had asked for. A calculation
> using the result displayed without rounding would use the non-rounded figure
> as you would require.
>
> Regards,
>
> Ian Fletcher.
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] Re: Rounding up/down error |
|
Author: Chris Whitford
Posted: Wed, 16 Jul 2003 17:20:55 +0100
|
I wonder whether some people are missing the point here. There is no law of
nature which says that 0.5 must round up. The IEEE floating point formats
(which the PC FP processor uses) say that 0.5 rounds to the nearest even
integer - 1.5 will round to 2 while 2.5 will also round to 2. But Mathcad
does numerical calculations with real numbers, which, except for special
cases, like integers, are approximated by floating point numbers. If you
are worried about the missing digits, display more of them! If you really
need 0.5 to mean exactly 1/2, you need to use the symbolic processor.
Chris
+------------------------------------------------------------------+
+ Chris Whitford University of Leicester +
+ Research Fellow Space Research Centre +
+ Tel: +44 (0)116 252 3496 Physics and Astronomy Department +
+ Fax: +44 (0)116 252 2464 University Road +
+ email: LEICESTER LE1 7RH +
+ http://www.star.le.ac.uk/ UK +
+------------------------------------------------------------------+
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] Re: Rounding up/down error |
|
Author: Shiner Adrian
Posted: Wed, 16 Jul 2003 18:36:06 +0200
|
Good point Chris. If the application is in engineering then the precision of
results are sufficient that lead to the physical product being to
requirements. As the engineer said to the mathematician in a certain
competition to win a lady's favour "I can get close enough for all practical
purposes".
I occasionally see building dimensions shown on drawings to decimal parts of
a millimetre! An understanding of the technology that you are working with
is always useful in order to avoid such howlers and sources of mirth.
Now if you are intent on calculating down to quantum dimensions then perhaps
its another matter, antimatter or dark matter as the case may be.
Best wishes
Adrian
-----Original Message-----
From: Chris Whitford />
Sent: 16 July 2003 17:21
To: Mathcad Discussion List
Subject: [mathcad] Re: Rounding up/down error
I wonder whether some people are missing the point here. There is no law of
nature which says that 0.5 must round up. The IEEE floating point formats
(which the PC FP processor uses) say that 0.5 rounds to the nearest even
integer - 1.5 will round to 2 while 2.5 will also round to 2. But Mathcad
does numerical calculations with real numbers, which, except for special
cases, like integers, are approximated by floating point numbers. If you
are worried about the missing digits, display more of them! If you really
need 0.5 to mean exactly 1/2, you need to use the symbolic processor.
Chris
+------------------------------------------------------------------+
+ Chris Whitford University of Leicester +
+ Research Fellow Space Research Centre +
+ Tel: +44 (0)116 252 3496 Physics and Astronomy Department +
+ Fax: +44 (0)116 252 2464 University Road +
+ email: LEICESTER LE1 7RH +
+ http://www.star.le.ac.uk/ UK +
+------------------------------------------------------------------+
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] Re: Rounding up/down error |
|
Author: Jean Rosenfeld
Posted: Wed, 16 Jul 2003 20:30:03 +0100
|
As I understand it the correct (all digits) value of a variable is always
carried through in any calculations, however it is displayed. The choice of
significant digits to display is a cosmetic matter that does not affect
calculations. For engineers just as for scientists (of whom I am one), the
cardinal rule is not to show more significant figures than are warranted by,
for example the uncertainty in the data or physical constants used. If this
rounding 'problem' worries anyone, they could show results to one more
figure than are truly significant, then do the final rounding themselves to
suit their taste.
Having said that, it does seem somewhat unfortunate that the convention used
in MathCAD is somewhat obscure when rounding a number whose last significant
digit has been entered as 5.
Some trial and error for numbers ending with the sequence pq5. If p is odd,
it rounds up whether q is even or odd. If p is even it rounds down if q is
even, but up if q is odd.
examples
x= 0.12345 formatted to 4 digits shows 0.1235 rounds up with p odd, q even
x= 0.12335 formatted to 4 digits shows 0.1234 rounds up with p odd, q odd
x= 0.12445 formatted to 4 digits shows 0.1244 rounds down with p even, q
even
x= 0.12235 formatted to 4 digits shows 0.1224 rounds up with p even, q odd
It is just unfortunate that the number that started this discussion was of
the 'anomalous' (p even, q even) type (well if it had not been there would
have been no discussion...). Of course, if you add the sequence 0000001 at
the end of the number, it rounds up also for this type, provided that the 1
is not beyond the number of places carried in MathCAD (e.g. for the 5 digit
numbers discussed here, you can insert up to 11 zeros before the 1 to flip
the result to rounding up). Doing this might be one way of solving the
display problem, without significantly affecting subsequent calculations.
--------------------------------------------------------
Jean L.J. Rosenfeld
Argoed Hall
Bryn-y-Baal
Mold
Flintshire CH7 6SQ
Wales, UK
Tel +44 1352 750566
E-mail />
-----Original Message-----
From: Shiner Adrian
Sent: 16 July 2003 17:36
To: Mathcad Discussion List
Subject: [mathcad] Re: Rounding up/down error
Good point Chris. If the application is in engineering then the precision of
results are sufficient that lead to the physical product being to
requirements. As the engineer said to the mathematician in a certain
competition to win a lady's favour "I can get close enough for all practical
purposes".
I occasionally see building dimensions shown on drawings to decimal parts of
a millimetre! An understanding of the technology that you are working with
is always useful in order to avoid such howlers and sources of mirth.
Now if you are intent on calculating down to quantum dimensions then perhaps
its another matter, antimatter or dark matter as the case may be.
Best wishes
Adrian
-----Original Message-----
From: Chris Whitford
Sent: 16 July 2003 17:21
To: Mathcad Discussion List
Subject: [mathcad] Re: Rounding up/down error
I wonder whether some people are missing the point here. There is no law of
nature which says that 0.5 must round up. The IEEE floating point formats
(which the PC FP processor uses) say that 0.5 rounds to the nearest even
integer - 1.5 will round to 2 while 2.5 will also round to 2. But Mathcad
does numerical calculations with real numbers, which, except for special
cases, like integers, are approximated by floating point numbers. If you
are worried about the missing digits, display more of them! If you really
need 0.5 to mean exactly 1/2, you need to use the symbolic processor.
Chris
+------------------------------------------------------------------+
+ Chris Whitford University of Leicester +
+ Research Fellow Space Research Centre +
+ Tel: +44 (0)116 252 3496 Physics and Astronomy Department +
+ Fax: +44 (0)116 252 2464 University Road +
+ email: LEICESTER LE1 7RH +
+ http://www.star.le.ac.uk/ UK +
+------------------------------------------------------------------+
---
The Mathcad List - Discussion, Support & News
Contributions:
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] Re: Rounding up/down error |
|
Author: Belshan, James E52
Posted: Wed, 16 Jul 2003 17:39:59 -0400
|
> Having said that, it does seem somewhat unfortunate that the
> convention used in MathCAD is somewhat obscure ...
Not to nit-pick, but this seems to be a little bit of a mis-statement. To
my understanding, MathCAD is programmed in a computer language, probably
C++. The programming language has a variety of variable types available,
which adhere to the IEEE standards. This is where you get the "round to the
even number" rule. MathCAD is not free to make its own rounding rules at
this level.
C++ (or whatever language it's written in) is not even to blame, really.
Since the computer uses binary, there are only certain numbers that it can
represent exactly (1/2, 1/4, 1/8, etc). So it may be that the closest
number it can store to 0.55 (for example only) is either 0.54999 or 0.55002,
leading to "anomalous" results.
What we need is for someone to invent a transistor with 10 states so we
could do normal "human" math.
James
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] Re: Rounding up/down error |
|
Author: Steve Ellison
Posted: Thu, 17 Jul 2003 10:41:37 +0100
|
Chris & co;
The numerical precision isn't causing this behaviour. Mathcad is apparently implementing ISO/IEEE round-to-even rules exactly correctly. Chris is correct as to the reason for that rule; on large data sets, always rounding 5 up causes a small positive bias (because only 9 (ie 1-9) of the ten available digits are ever rounded - noone rounds zero. To have rounding average out to zero, half the digits must round up and half down. Half of 9 is 4.5 - which means one needs to be rounded up half the time).
The 'unexpectedness' arises partly because the round-toeven rule is relatively recent and rarely taght at school. Also, though, any rounding rules do odd things if you progressively round; 1.50 rounds to 2 under most rounding rules, but 1.49 rounds correctly to 1.5 to two sig figs, and correctly to 1.0 if rounded to one sig fig. Only if you incorrectly round first from 1.49 to 1.5 and then round 1.5 does is get inconsistent. Moral 1 - never round progressively!
Also, don't round if it matters! Remember we only round for reporting convenience (or sometimes paper calculation); in either case, the general rule is never to throw away significant information. So no argument over rounding behaviour should, almost by definition, ever be important. :)
Steve E.
>>> 15/07/2003 09:04:29 >>>
I suspect the reason is this: numbers are represented internally by a
normalised mantissa (52 bits) times a power of 2. Most decimal fractions
cannot be represented exactly, so some rounding takes place. Then when you
display the number, it is converted back to decimal, and it gets rounded
again. The first rounding could take it up or down, by a very tiny amount.
The actual IEEE floating point format specifies that if the number ends in
exactly 0.5, it is rounded to the nearest even integer. So 1.5 and 2.5 are
both rounded to 2. This is so that, statistically, 0.5 is rounded up or
down with equal probablility.
Chris
At 09:12 15/07/2003 +0200, you wrote:
>I have been using a calculation with a number of 0.04425 N/mm^2. However,
>I noticed a strange behavior when I modified the properties of a result to
>show me 4 digits. Normally, it would then show me 0.0443 as a 5 always
>rounds up. However, as you can see in the attached mathcad-sheet, MathCad
>decides that it does not want to show 0.0443, but 0.0442. I have been
>playing with a few other numbers, but this is the only one I have found.
>Can someone tell me, whether this is a bug in MathCad, or that there is an
>option included in MathCad that makes sure that some results are rounded
>to a different value? (Or perhaps someone else has encountered the same
>rounding error somewhere else...)
+------------------------------------------------------------------+
+ Chris Whitford University of Leicester +
+ Research Fellow Space Research Centre +
+ Tel: +44 (0)116 252 3496 Physics and Astronomy Department +
+ Fax: +44 (0)116 252 2464 University Road +
+ email: LEICESTER LE1 7RH +
+ http://www.star.le.ac.uk/ UK +
+------------------------------------------------------------------+
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
*******************************************************************
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If
you have received this message in error, please notify the sender
immediately via +44(0)20 8943 7000 or notify
and delete this message and any copies from your computer and network.
LGC Limited. Registered in England 2991879.
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] Re: Rounding up/down error |
|
Author: Steve Ellison
Posted: Thu, 17 Jul 2003 10:53:13 +0100
|
To call Mathcad's rounding convention 'obscure' is confusing public awareness with technical best practice. Round to even is best technical practice for numerical data handling and pretty well any top-level maths package should be implementing it. But you;re right - not a lot of people know that.
>>> 16/07/2003 20:30:03 >>>
As I understand it the correct (all digits) value of a variable is always
carried through in any calculations, however it is displayed. The choice of
significant digits to display is a cosmetic matter that does not affect
calculations. For engineers just as for scientists (of whom I am one), the
cardinal rule is not to show more significant figures than are warranted by,
for example the uncertainty in the data or physical constants used. If this
rounding 'problem' worries anyone, they could show results to one more
figure than are truly significant, then do the final rounding themselves to
suit their taste.
Having said that, it does seem somewhat unfortunate that the convention used
in MathCAD is somewhat obscure when rounding a number whose last significant
digit has been entered as 5.
Some trial and error for numbers ending with the sequence pq5. If p is odd,
it rounds up whether q is even or odd. If p is even it rounds down if q is
even, but up if q is odd.
examples
x= 0.12345 formatted to 4 digits shows 0.1235 rounds up with p odd, q even
x= 0.12335 formatted to 4 digits shows 0.1234 rounds up with p odd, q odd
x= 0.12445 formatted to 4 digits shows 0.1244 rounds down with p even, q
even
x= 0.12235 formatted to 4 digits shows 0.1224 rounds up with p even, q odd
It is just unfortunate that the number that started this discussion was of
the 'anomalous' (p even, q even) type (well if it had not been there would
have been no discussion...). Of course, if you add the sequence 0000001 at
the end of the number, it rounds up also for this type, provided that the 1
is not beyond the number of places carried in MathCAD (e.g. for the 5 digit
numbers discussed here, you can insert up to 11 zeros before the 1 to flip
the result to rounding up). Doing this might be one way of solving the
display problem, without significantly affecting subsequent calculations.
--------------------------------------------------------
Jean L.J. Rosenfeld
Argoed Hall
Bryn-y-Baal
Mold
Flintshire CH7 6SQ
Wales, UK
Tel +44 1352 750566
E-mail
-----Original Message-----
From: Shiner Adrian
Sent: 16 July 2003 17:36
To: Mathcad Discussion List
Subject: [mathcad] Re: Rounding up/down error
Good point Chris. If the application is in engineering then the precision of
results are sufficient that lead to the physical product being to
requirements. As the engineer said to the mathematician in a certain
competition to win a lady's favour "I can get close enough for all practical
purposes".
I occasionally see building dimensions shown on drawings to decimal parts of
a millimetre! An understanding of the technology that you are working with
is always useful in order to avoid such howlers and sources of mirth.
Now if you are intent on calculating down to quantum dimensions then perhaps
its another matter, antimatter or dark matter as the case may be.
Best wishes
Adrian
-----Original Message-----
From: Chris Whitford
Sent: 16 July 2003 17:21
To: Mathcad Discussion List
Subject: [mathcad] Re: Rounding up/down error
I wonder whether some people are missing the point here. There is no law of
nature which says that 0.5 must round up. The IEEE floating point formats
(which the PC FP processor uses) say that 0.5 rounds to the nearest even
integer - 1.5 will round to 2 while 2.5 will also round to 2. But Mathcad
does numerical calculations with real numbers, which, except for special
cases, like integers, are approximated by floating point numbers. If you
are worried about the missing digits, display more of them! If you really
need 0.5 to mean exactly 1/2, you need to use the symbolic processor.
Chris
+------------------------------------------------------------------+
+ Chris Whitford University of Leicester +
+ Research Fellow Space Research Centre +
+ Tel: +44 (0)116 252 3496 Physics and Astronomy Department +
+ Fax: +44 (0)116 252 2464 University Road +
+ email: LEICESTER LE1 7RH +
+ http://www.star.le.ac.uk/ UK +
+------------------------------------------------------------------+
---
The Mathcad List - Discussion, Support & News
Contributions:
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
*******************************************************************
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If
you have received this message in error, please notify the sender
immediately via +44(0)20 8943 7000 or notify
and delete this message and any copies from your computer and network.
LGC Limited. Registered in England 2991879.
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] Re: Rounding up/down error |
|
Author: Bruff, Stuart
Posted: Thu, 17 Jul 2003 12:38:07 +0100
|
As another example of 'obscure', whilst an Excel 97 worksheet 'rounds' the
display up, the VBA FORMAT statement rounds down.
Worksheet
0.04425 Number as entered
0.0443 Number displayed to 4 decimal places
VBA
Debug.Print Format(0.04425, "0.0000")
0.0442
And, as I mentioned in my earlier email, both Axum 7 and Matlab round this
number down. The method may be obscure, but it's not a 'Mathcad' issue per
se.
If it's of any interest, Mathcad's symbolic processor gives the following
binary representation of 0.04425 to 64 places:
1.01101010011111101111100111011011001000101101000011[1001010110000]*10^-5
(my brackets)
Obviously, any 53 bit mantissa representation of 0.04425 must lose the last
13 digits of this more exact binary representation, and round up or down -
which means 0.04425 may be represented by a number < 0.04425 or > but not
0.04425. Any rounding algorithm will deal with the floating point
representation.
Stuart
Stuart Bruff
Senior Systems Engineer
Studies Group
Alenia Marconi Systems Limited
Lyon Way, Frimley, Camberley, Surrey.
GU16 7EX
United Kingdom
GNET : 822-5604
Tel No: +44(0)1276-468604
EMAIL: />
-----Original Message-----
From: Steve Ellison />
Sent: Thursday, July 17, 2003 10:53
To: Mathcad Discussion List
Subject: [mathcad] Re: Rounding up/down error
*** WARNING ***
This mail has originated outside your organization,
either from an external partner or the Global Internet.
Keep this in mind if you answer this message.
To call Mathcad's rounding convention 'obscure' is confusing public
awareness with technical best practice. Round to even is best technical
practice for numerical data handling and pretty well any top-level maths
package should be implementing it. But you;re right - not a lot of people
know that.
>>> 16/07/2003 20:30:03 >>>
As I understand it the correct (all digits) value of a variable is always
carried through in any calculations, however it is displayed. The choice of
significant digits to display is a cosmetic matter that does not affect
calculations. For engineers just as for scientists (of whom I am one), the
cardinal rule is not to show more significant figures than are warranted by,
for example the uncertainty in the data or physical constants used. If this
rounding 'problem' worries anyone, they could show results to one more
figure than are truly significant, then do the final rounding themselves to
suit their taste.
Having said that, it does seem somewhat unfortunate that the convention used
in MathCAD is somewhat obscure when rounding a number whose last significant
digit has been entered as 5.
Some trial and error for numbers ending with the sequence pq5. If p is odd,
it rounds up whether q is even or odd. If p is even it rounds down if q is
even, but up if q is odd.
examples
x= 0.12345 formatted to 4 digits shows 0.1235 rounds up with p odd, q even
x= 0.12335 formatted to 4 digits shows 0.1234 rounds up with p odd, q odd
x= 0.12445 formatted to 4 digits shows 0.1244 rounds down with p even, q
even
x= 0.12235 formatted to 4 digits shows 0.1224 rounds up with p even, q odd
It is just unfortunate that the number that started this discussion was of
the 'anomalous' (p even, q even) type (well if it had not been there would
have been no discussion...). Of course, if you add the sequence 0000001 at
the end of the number, it rounds up also for this type, provided that the 1
is not beyond the number of places carried in MathCAD (e.g. for the 5 digit
numbers discussed here, you can insert up to 11 zeros before the 1 to flip
the result to rounding up). Doing this might be one way of solving the
display problem, without significantly affecting subsequent calculations.
--------------------------------------------------------
Jean L.J. Rosenfeld
Argoed Hall
Bryn-y-Baal
Mold
Flintshire CH7 6SQ
Wales, UK
Tel +44 1352 750566
E-mail
-----Original Message-----
From: Shiner Adrian
Sent: 16 July 2003 17:36
To: Mathcad Discussion List
Subject: [mathcad] Re: Rounding up/down error
Good point Chris. If the application is in engineering then the precision of
results are sufficient that lead to the physical product being to
requirements. As the engineer said to the mathematician in a certain
competition to win a lady's favour "I can get close enough for all practical
purposes".
I occasionally see building dimensions shown on drawings to decimal parts of
a millimetre! An understanding of the technology that you are working with
is always useful in order to avoid such howlers and sources of mirth.
Now if you are intent on calculating down to quantum dimensions then perhaps
its another matter, antimatter or dark matter as the case may be.
Best wishes
Adrian
-----Original Message-----
From: Chris Whitford
Sent: 16 July 2003 17:21
To: Mathcad Discussion List
Subject: [mathcad] Re: Rounding up/down error
I wonder whether some people are missing the point here. There is no law of
nature which says that 0.5 must round up. The IEEE floating point formats
(which the PC FP processor uses) say that 0.5 rounds to the nearest even
integer - 1.5 will round to 2 while 2.5 will also round to 2. But Mathcad
does numerical calculations with real numbers, which, except for special
cases, like integers, are approximated by floating point numbers. If you
are worried about the missing digits, display more of them! If you really
need 0.5 to mean exactly 1/2, you need to use the symbolic processor.
Chris
+------------------------------------------------------------------+
+ Chris Whitford University of Leicester +
+ Research Fellow Space Research Centre +
+ Tel: +44 (0)116 252 3496 Physics and Astronomy Department +
+ Fax: +44 (0)116 252 2464 University Road +
+ email: LEICESTER LE1 7RH +
+ http://www.star.le.ac.uk/ UK +
+------------------------------------------------------------------+
---
The Mathcad List - Discussion, Support & News
Contributions:
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
*******************************************************************
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If
you have received this message in error, please notify the sender
immediately via +44(0)20 8943 7000 or notify
and delete this message and any copies from your computer and network.
LGC Limited. Registered in England 2991879.
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] Re: Rounding up/down error |
|
Author: Pergande, Albert N
Posted: Thu, 17 Jul 2003 08:29:22 -0400
|
Round to even dates back to steam engine and slide rule days - by
rounding to even, subsequent calculations where very slightly easier,
since numbers that end in an even digit as easier to divide by 2.
It's sort of like the roman carriage wheel width standard driving modern
railroad gages.
-----Original Message-----
From: Steve Ellison />
Sent: Thursday, July 17, 2003 5:42 AM
To: Mathcad Discussion List
Subject: [mathcad] Re: Rounding up/down error
Chris & co;
The numerical precision isn't causing this behaviour. Mathcad is
apparently implementing ISO/IEEE round-to-even rules exactly correctly.
Chris is correct as to the reason for that rule; on large data sets,
always rounding 5 up causes a small positive bias (because only 9 (ie
1-9) of the ten available digits are ever rounded - noone rounds zero.
To have rounding average out to zero, half the digits must round up and
half down. Half of 9 is 4.5 - which means one needs to be rounded up
half the time).
The 'unexpectedness' arises partly because the round-toeven rule is
relatively recent and rarely taght at school. Also, though, any rounding
rules do odd things if you progressively round; 1.50 rounds to 2 under
most rounding rules, but 1.49 rounds correctly to 1.5 to two sig figs,
and correctly to 1.0 if rounded to one sig fig. Only if you incorrectly
round first from 1.49 to 1.5 and then round 1.5 does is get
inconsistent. Moral 1 - never round progressively!
Also, don't round if it matters! Remember we only round for reporting
convenience (or sometimes paper calculation); in either case, the
general rule is never to throw away significant information. So no
argument over rounding behaviour should, almost by definition, ever be
important. :)
Steve E.
>>> 15/07/2003 09:04:29 >>>
I suspect the reason is this: numbers are represented internally by a
normalised mantissa (52 bits) times a power of 2. Most decimal fractions
cannot be represented exactly, so some rounding takes place. Then when
you
display the number, it is converted back to decimal, and it gets rounded
again. The first rounding could take it up or down, by a very tiny
amount.
The actual IEEE floating point format specifies that if the number ends
in
exactly 0.5, it is rounded to the nearest even integer. So 1.5 and 2.5
are
both rounded to 2. This is so that, statistically, 0.5 is rounded up or
down with equal probablility.
Chris
At 09:12 15/07/2003 +0200, you wrote:
>I have been using a calculation with a number of 0.04425 N/mm^2.
However,
>I noticed a strange behavior when I modified the properties of a result
to
>show me 4 digits. Normally, it would then show me 0.0443 as a 5 always
>rounds up. However, as you can see in the attached mathcad-sheet,
MathCad
>decides that it does not want to show 0.0443, but 0.0442. I have been
>playing with a few other numbers, but this is the only one I have
found.
>Can someone tell me, whether this is a bug in MathCad, or that there is
an
>option included in MathCad that makes sure that some results are
rounded
>to a different value? (Or perhaps someone else has encountered the same
>rounding error somewhere else...)
+------------------------------------------------------------------+
+ Chris Whitford University of Leicester +
+ Research Fellow Space Research Centre +
+ Tel: +44 (0)116 252 3496 Physics and Astronomy Department +
+ Fax: +44 (0)116 252 2464 University Road +
+ email: LEICESTER LE1 7RH +
+ http://www.star.le.ac.uk/ UK +
+------------------------------------------------------------------+
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
*******************************************************************
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If
you have received this message in error, please notify the sender
immediately via +44(0)20 8943 7000 or notify />
and delete this message and any copies from your computer and network.
LGC Limited. Registered in England 2991879.
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] Re: Rounding up/down error |
|
Author: Pergande, Albert N
Posted: Thu, 17 Jul 2003 08:30:24 -0400
|
That would be an analog computer, preferable made from 6AU6 based op
amps.
-----Original Message-----
From: Belshan, James (E52) />
Sent: Wednesday, July 16, 2003 5:40 PM
To: Mathcad Discussion List
Subject: [mathcad] Re: Rounding up/down error
> Having said that, it does seem somewhat unfortunate that the
> convention used in MathCAD is somewhat obscure ...
Not to nit-pick, but this seems to be a little bit of a mis-statement.
To
my understanding, MathCAD is programmed in a computer language, probably
C++. The programming language has a variety of variable types
available,
which adhere to the IEEE standards. This is where you get the "round to
the
even number" rule. MathCAD is not free to make its own rounding rules
at
this level.
C++ (or whatever language it's written in) is not even to blame, really.
Since the computer uses binary, there are only certain numbers that it
can
represent exactly (1/2, 1/4, 1/8, etc). So it may be that the closest
number it can store to 0.55 (for example only) is either 0.54999 or
0.55002,
leading to "anomalous" results.
What we need is for someone to invent a transistor with 10 states so we
could do normal "human" math.
James
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
| [mathcad] Re: Rounding up/down error |
|
Author: Colonna De Lega, Xavier
Posted: Thu, 17 Jul 2003 08:50:07 -0400
|
> -----Original Message-----
> From: Steve Ellison />
> Sent: Thursday, July 17, 2003 05:42
> To: Mathcad Discussion List
> Subject: [mathcad] Re: Rounding up/down error
>
> The 'unexpectedness' arises partly because the round-toeven
> rule is relatively recent and rarely taght at school. Also,
> though, any rounding rules do odd things if you progressively
> round; 1.50 rounds to 2 under most rounding rules, but 1.49
> rounds correctly to 1.5 to two sig figs, and correctly to 1.0
> if rounded to one sig fig. Only if you incorrectly round
> first from 1.49 to 1.5 and then round 1.5 does is get
> inconsistent. Moral 1 - never round progressively!
I fully agree with your general statement. However, just to be picky, I
would rephrase the above sentence a little bit: "1.49 rounds correctly to
1.5 to two sig figs, and correctly to 1 if rounded to one sig fig".
Xavier
---
The Mathcad List - Discussion, Support & News
Contributions: />
Hosted by: Adept Scientific http://www.adeptscience.com
List Archive: http://lists.adeptscience.co.uk/
---
Would you like this to come to a different email address?
---
Simply leave the mailing list (see below) and re-join by
sending a blank email from the new address to:
or
---
If you do not want to be on the Mathcad list, simply send a
blank email (no subject or message needed) to:
/>
|
Previous by date: [mathcad] Rounding up/down error, Sander Lablans
Next by date: [mathcad] [mathcad]Re: Rounding up/down error, Markos E Psarros
Previous thread: [mathcad] Axum function princomp, Bruff, Stuart
Next thread: [mathcad] [mathcad]Re: Rounding up/down error, Markos E Psarros
|
|
|