+ Reply to Thread
Results 1 to 6 of 6

Problem with the MOD function

  1. #1
    Registered User
    Join Date
    11-22-2014
    Location
    Latvia
    MS-Off Ver
    2013
    Posts
    2

    Problem with the MOD function

    Hey guys!

    I'm quite new here (registered 8 minutes ago) and have discovered a weird situation in Excel.

    I'm using Excel 2013 and entering this function gives me weird result:

    Please Login or Register  to view this content.
    That results in 0.0001

    Evaluating the function reveals that it results in 0.0000999999999...

    I know this is beacause of the way Excel handles numbers in general, but my question is what would be the best way around this particular situation.

    Thank you in advance!
    Last edited by Marchack; 11-22-2014 at 06:39 AM. Reason: Solved

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Problem with the MOD function

    Yes - the problem is caused by the way Excel counts numbers (binary floating point). Best workaround is to multiply by 10,000, do the mod and divide by 10,000 again
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    11-22-2014
    Location
    Latvia
    MS-Off Ver
    2013
    Posts
    2

    Re: Problem with the MOD function

    That works, thanks!

    Is there any hope this might be fixed someday?

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Problem with the MOD function

    I doubt it!! This is Microsoft we're talking about...

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

    Re: Problem with the MOD function

    Quote Originally Posted by Glenn Kennedy View Post
    Yes - the problem is caused by the way Excel counts numbers (binary floating point). Best workaround is to multiply by 10,000, do the mod and divide by 10,000 again
    But be sure the results are integers. In an Excel file, Glenn wrote: =MOD(10000*A1,10000*B1)/10000. That worked with B1=0.0025. It does not work with B1=0.0024.

    The following does work: =MOD(ROUND(A1*10000,0),ROUND(B1*10000,0))/10000.

    The problem is: most non-integers cannot be represented exactly in binary; so A1*10000 or B1*10000 might not result in an integer. Compounding confusion: Excel arbitrarily formats only the first 15 significant digits. So 0.0024*10000 looks like 24.0000000000000, but it is actually 23.9999999999999,96447286321199499070644378662109375.

    (I use period for the decimal point and comma to demarcate 15 significant digits.)

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Problem with the MOD function

    Fair point...

+ 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: 6
    Last Post: 10-20-2013, 07:16 PM
  2. MID function problem
    By alfgrey in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-11-2013, 06:50 AM
  3. Problem Inserting Round function into an IF function
    By Ash87 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-11-2013, 05:37 PM
  4. Function Problem
    By SPORTS96 in forum Excel General
    Replies: 9
    Last Post: 02-16-2007, 06:32 PM
  5. [SOLVED] if Function problem
    By jerry in forum Excel General
    Replies: 8
    Last Post: 10-03-2005, 02:05 PM

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