Home
Forums
New posts
Search forums
Articles
Latest reviews
Search resources
Members
Current visitors
Newsgroups
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Discussion
excel rounding error?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Joe User, post: 13711843"] I can explain the difference, but it can get very technical. I could probably explain things better if you provided the VBA example. But generally.... Both Excel and VBA (for type Double) store numbers using the IEEE 64-bit floating-point form. However, Intel-compatible CPUs use 80-bit floating-point registers to perform computations. The 80-bit FP form extends both the precision and the range of values. Excel stores the 80-bit result of each pairwise arithmetic operation into 64-bit variables, which causes a loss of precision. VBA tries to keep intermediate results in the 80-bit form. That does not always lead to differences in the result. Usually, that depends on the order and magnitude of the pairwise arithmetic operations. In summary, the expression Min/60/24 is evaluated by both Excel and VBA as x = Min/60, then x/24. Likewise, Min/24/60 is evaluated as x = Min/24, then x/60. Mathematically, there is no difference. But when the results of the pairwise operations cannot be represented exactly in a finite number of bits, the order of operations can make a small difference in the least-significant bits. Moreover, a difference can arise when Min/24 or Min/60 is converted from 80-bit FP to 64-bit FP, as Excel does. The operative word is "can"; sometimes there is no difference. I hope that helps. ----- original message ----- Thank you both for your replies. Joe - I've noticed the difference between Excel and VBA as well. I tried to reproduce an error present in some VBA code (subtracting times) but was unable to - there didn't seem to be any correlation between the two calculation methods (i.e. i couldn't discern a pattern between the numbers being subtracted and whether the rounding error was above or below, or if it was exact). [/QUOTE]
Verification
Post reply
Home
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Discussion
excel rounding error?
Top