 |
|
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: 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:
/>
|
[View Complete Thread]
Previous by date: [mathcad] Re: Rounding up/down error, Steve Ellison
Next by date: [mathcad] Re: Rounding up/down error, Pergande, Albert N
Previous thread: [mathcad] [mathcad]Re: Rounding up/down error, Markos E Psarros
Next thread: [mathcad] Re: Rounding up/down error, Chris Whitford
|
|
|