+ Reply to Thread
Results 1 to 6 of 6

Calculation problem

  1. #1
    Registered User
    Join Date
    01-30-2016
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    17

    Calculation problem

    Below you can see a very simple formula (the ALS-formula is just the Dutch translation of the IF-formula) and calculation:

    Excel.png

    How is this possible? Why is the value of cell A3 not zero?

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Calculation problem

    Please post a file (not least because many of us cannot see images) and we need data to work with.

  3. #3
    Registered User
    Join Date
    01-30-2016
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    17

    Re: Calculation problem

    Here you go.

    Krediet.xlsx

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

  5. #5
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Calculation problem

    Quote Originally Posted by _Nebur_ View Post
    How is this possible? Why is the value of cell A3 not zero?
    The simple answer is: when you expect an arithmetic result to be accurate to some degree of precision, you should explicitly round to that number of decimal places.

    In your example, =IF(C6>0,C11-G3,0) should be =IF(C6>0,ROUND(C11-G3,2)) in Mensualiteit!H3.

    Note: I use comma to separate parameters; you use semicolon.

    Of course, you should make similar changes elsewhere.

    To explain....

    This is a common(!) anomaly of 64-bit binary floating-point, which Excel uses to represent numbers and perform arithmetic.

    Most decimal fractions cannot be represented exactly. Instead, they are approximated by the sum of 53 consecutive powers of 2 ("bits") times an exponential factor. For example, 0.1 (1/10) is represented by 1/16 + 1/32 + 0/64 + 0/128 + 1/256 + ....

    Moreover, because there are only 53 bits to represent the integer part as well, the number of bits available for the approximation of the decimal fraction varies. Consequently, the approximation of the decimal fraction is not the same in the representation of all values.

    For example, IF(10.1 - 10 = 0.1, TRUE) returns FALSE(!) because the approximation of 0.1 in 10.1 is not the same as the approximation of 0.1 itself. In 10.1, 4 bits are used to represent 10, leaving only 49 bits to represent 0.1. But in 0.1 itself, all 53 bits are used to form the approximation.

    Your example is similar. In 124.15 in Mensualiteit!G3, 6 bits are used to represent 124, leaving 47 bits to approximate 0.15. But in 100,124.15 in Mensualiteit!C11, 16 bits are used to represent 100,124, leaving 37 bits to approximate 0.15.

    Compounding the problem: the result of the formula in C11 is not properly rounded to 2 decimal places, highlighting the fallacy of using CEILING(...,0.01) with that intent. Generally, CEILING is unreliable when the second parameter has a decimal fraction (other than a power of 2). In this case, it is better to use ROUNDUP(...,2).

    So these are the exact values in the Mensualiteit worksheet:
    Please Login or Register  to view this content.
    Note: I use period for the decimal point and comma to demarcate the first 15 significant digits, which is all that Excel formats, an arbitrary limit.

    Note that H3 would be exactly 10000 if you use ROUNDUP in C11. But that is only a coincidence. It is still prudent to use ROUND(...,2) in H3.
    Last edited by joeu2004; 01-30-2016 at 02:08 PM. Reason: cosmetic; typo: missing "not"; typo: ROUND(...,2), not 0

  6. #6
    Registered User
    Join Date
    01-30-2016
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    17

    Re: Calculation problem

    Okay, thanks for the replies. :-)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 01-15-2013, 08:51 AM
  2. Need Help in a tax calculation problem
    By vijaysin20 in forum Excel General
    Replies: 2
    Last Post: 10-01-2012, 12:14 AM
  3. [SOLVED] Calculation Problem
    By Daywalker in forum Excel General
    Replies: 9
    Last Post: 09-25-2009, 02:46 AM
  4. Calculation Problem
    By bengaluru in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-09-2009, 12:49 PM
  5. calculation problem
    By wwoody in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-30-2006, 01:27 AM
  6. Calculation Problem
    By spiney in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-10-2006, 01:29 PM
  7. [SOLVED] calculation problem
    By les in forum Excel General
    Replies: 1
    Last Post: 11-24-2005, 07:40 AM
  8. Calculation problem
    By Ajtb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2005, 05:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1