Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Jerry W. Lewis
 
Posts: n/a
Default

"Bruno Campanini" wrote:

They are not affected by floating point bugs.


To call this a "bug" stretches the definition of "bug". Is it a "bug"
that you cannot write 1/3 exactly as a decimal fraction?


No, but there is somwhere a "bug" when adding 100 times
0.01 to 0 I can't get 1.


As I pointed out in my original post to this thread, "most decimal fractions
have no exact binary representation" and so must be approximated. The
approximation to 0.01 is
0.100000000000000002081668171172168513294309377670 2880859375, so it should
not be surprising that when you add 100 values which are each slightly larger
than you expected, that the total will also be slightly larger than you
expected. Taking account of the intermediate roundings (also covered by the
IEEE standard) that will occur, the sum of 100 such approximate values will be
1 + 6.661338147750939242541790008544921875E-16
The Excel formula =(total-1) will return 6.66133814775094E-16 (Excel's
documented 15-digit limit) indicating that the arithmetic is working exactly
as it should.

As I also said in my original post "When you have to approximate your
inputs, that the output is only approximate should be no surprise."

You can see the same phenomenon in decimal (where it may have more
intuition). If you use the VBA Currency data type (4 decimal places)
x = CCur(1 / 3)
total = x + x + x
The value of total will be 0.9999, not 1.0000. Surely you will agree that
there is no bug there.

If you don't want to use the word "bug" suggest me what is
the proper word.


I am open to suggestions, but calling correct math based on necessary
approximations to inputs a "bug" is rather like complaining that it shouldn't
rain. It seems a pointless waste of effort that would be better directed at
learning to predict when it will rain and how to protect yourself when it
does.

If you cannot tolerate slight approximations beyond the 15th significant
figure, then you should stick to integer calculations where those
approximations can be avoided. If you continue to work with decimal
fractions, you should be aware that digits beyond the 15th may not be what
you expect, and subtractions (including the MOD function) may remove some or
even all of the leading digits that originally prevented you from seeing the
approximation. Rounding calculated values to the number of places that you
can be sure of, will usually help you avoid surprises.

These are issues that have been around as long as computers have been doing
finite precision mathematics (long before there was a Microsoft), and are not
unique to Excel.

Jerry
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
undefined function error when creating xls pivot from mdb qry andrew Excel Worksheet Functions 0 July 29th 05 07:26 PM
MROUND function. Getting the following error: #NAME? masoud Excel Worksheet Functions 2 June 29th 05 11:19 AM
How can I download and install ERROR FUNCTION in Excel 2003? ERF. Zhiming Qi Excel Worksheet Functions 2 April 25th 05 01:15 PM
Error message when inserting function Ajay Excel Discussion (Misc queries) 0 April 18th 05 04:28 PM
Vlookup & Lookup function error Beginner Excel Worksheet Functions 9 January 11th 05 12:37 AM


All times are GMT +1. The time now is 10:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"