+ Reply to Thread
Results 1 to 5 of 5

Strange MOD() result?

  1. #1
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Strange MOD() result?

    Hi,

    In another topic someone asked the amount of char before/after a decimal point
    Example: [D14]=123456.1234 should give 6 before and 4 after

    =LEN(INT(D14)) which works fine
    =LEN(MOD(D14;1)-2) gives 17
    This is because MOD(D14;1) = 0,123999999999999

    Is it me, or is it MOD() ?

    Ricardo
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  2. #2
    Forum Expert
    Join Date
    09-09-2005
    Location
    England
    MS-Off Ver
    2007
    Posts
    1,500
    This is down to they way excel stores numbers and the conversion between binary and decimal. There is not an easy answer

    http://www.cpearson.com/excel/rounding.htm

    explains the issue in more detail

    Regards

    Dav

  3. #3
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    re: Strange MOD() result?

    Thx Dav for sending the link,

    Figured there was no easy way out.

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    If you have the formula

    =LEN(INT(D14))

    in cell E14 for the number of digits before the decimal place then try this formula for the number of digits after

    =MAX(0;LEN(D14)-E14-1)

  5. #5
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671
    Daddylonglegs,
    I've used a similar function using the IF() for the (-1) caused by the comma. The Max is certainly more elegant. Great.

+ 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. Spellnumber
    By Williams in forum Excel - New Users/Basics
    Replies: 13
    Last Post: 02-16-2020, 03:34 AM
  2. Numbers to Text
    By sachinattri in forum Excel General
    Replies: 6
    Last Post: 06-15-2008, 03:07 AM
  3. "Translating" numbers into words
    By Portuga in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-14-2008, 11:44 AM
  4. Read time from Excel Sheet give strange result
    By abhay in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2007, 05:06 AM
  5. Spell number
    By nowfal in forum Excel General
    Replies: 4
    Last Post: 08-20-2007, 04:21 PM

Tags for this Thread

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