+ Reply to Thread
Results 1 to 8 of 8

Truncating a number to cancel any latent digits beyond 2

  1. #1
    Forum Contributor
    Join Date
    04-23-2014
    Location
    Liverpool...ish
    MS-Off Ver
    Excel 2013
    Posts
    126

    Truncating a number to cancel any latent digits beyond 2

    I am for some reason having problems with this formula. I am using it in conjunction with conditional formating that says if the difference between the some of BC and BD 213 is Greater/Less Than/=To the some of BH:CY213 then the cell will return that difference with a color( yellow=greater, Green= 0.00, Red= Less). The problem that I find randomly is that sometimes the difference shows 0.00 but shows red or yellow. Extending the resulting number out to 30 places shows that these numbers somehow show a number +/- out in the 23rd place. All of the numbers summed in the formula are formated currency in GBP to 2 places. The summed numbers do not show anything but 0 beyond the two digits I formated the cell for. I am not great at creating formula so have attempted to insert rounding and truncating functions without success (receive formula errors). Can someone show or explain to me how to kill any digits beyond 2.

    Please Login or Register  to view this content.
    Thanks In Advance
    Scott

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,369

    Re: Truncating a number to cancel any latent digits beyond 2

    Impossible to troubleshoot without seeing it in context! Please provide a sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Truncating a number to cancel any latent digits beyond 2

    It sounds like you're experiencing issues with floating point precision, possibly caused by adding negative numbers.

    Nesting your SUM formulas inside of ROUND should fix it, i.e. change =SUM(.....) to =ROUND(SUM(.....),2) with the 2 at the end being the number of digits to round to.

  4. #4
    Forum Contributor
    Join Date
    04-23-2014
    Location
    Liverpool...ish
    MS-Off Ver
    Excel 2013
    Posts
    126

    Re: Truncating a number to cancel any latent digits beyond 2

    My desire was to truncate the resulting number created by the difference however I suppose finding out why

    39.730000000000000000000000000000
    - 39.730000000000000000000000000000
    ---------------------------------
    -0.000000000000007105427357601000. I have extended the formatting of all relevant cells in row 9,including blank ones, to 30 places.

    If their is no easy explanation for these phantom numbers could someone tell me how to rewrite the formula to remove all digits beyond the 2 that most currencies operate in
    Attached Files Attached Files

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,369

    Re: Truncating a number to cancel any latent digits beyond 2

    Did you read post #3?

    Explanation: https://www.spreadsheetweb.com/float...-issues-excel/

    This, maybe?

    =IF(ISNUMBER(OFFSET(F3,-1,0)),ROUND((B3+C3),0)-ROUND(SUM(G3:AX3),0),0)

    Or:

    =IF(ISNUMBER(OFFSET(F3,-1,0)),ROUND((B3+C3),2)-ROUND(SUM(G3:AX3),2),0)
    Last edited by AliGW; 07-14-2019 at 06:41 AM.

  6. #6
    Forum Contributor
    Join Date
    04-23-2014
    Location
    Liverpool...ish
    MS-Off Ver
    Excel 2013
    Posts
    126

    Re: Truncating a number to cancel any latent digits beyond 2

    Interesting... I had originally attempted to do this and got a formula error which I couldn't figure out how to resolve. I must have typed something wrong because this time it worked a treat. This is what I was looking for. But I suppose Ali has a point, the numbers all show that none of the summed numbers have digits that extend beyond the 2nd place... Knowing why they sum this way would be informative although they do not have any affect on the results of this workbook, only the visual error induced by the conditional format.

    Thanks for your help... If we can find no direct explanation for the problem I will use your solution which is what I asked for.

    Regards Scott.

  7. #7
    Forum Contributor
    Join Date
    04-23-2014
    Location
    Liverpool...ish
    MS-Off Ver
    Excel 2013
    Posts
    126

    Re: Truncating a number to cancel any latent digits beyond 2

    The posts passed in the dark..... I didn't think the solution actually required a worksheet example but worked one up for you.

    Scott

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,369

    Re: Truncating a number to cancel any latent digits beyond 2

    Have you read the article? Computers work in binary - these are decimal numbers. It is the conversions that go on 'under the bonnet' that cause the issues. This is may layman's explanation!!!

+ 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. How to ID digits within a group of 8-digits that equal a specified number
    By Thunder001 in forum Excel Formulas & Functions
    Replies: 31
    Last Post: 07-04-2019, 02:49 AM
  2. Replies: 2
    Last Post: 11-28-2014, 07:09 AM
  3. Check most frequent number in 1 column that has 4 digits number
    By Merson78 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 06-07-2014, 10:57 PM
  4. VLOOKUP's Latent Memory
    By bobbylowe in forum Excel General
    Replies: 14
    Last Post: 09-02-2010, 12:07 AM
  5. Replies: 3
    Last Post: 02-12-2009, 01:08 PM
  6. Replies: 5
    Last Post: 12-08-2008, 11:47 AM
  7. How to cancel number rounding?
    By SSAAFF in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-28-2005, 01: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