+ 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 2010
    Posts
    120

    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
    Ipswich, England
    MS-Off Ver
    Excel 2016 (Win 10 - Work) & 365 Subscription (Win 10 - Home)
    Posts
    27,600

    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!

    STOP PRESS: Forum Rules Updated September 2018! Please read them here.
    Are you new to Power Query and don't know what to do with the code you've been given? Have a look here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    swindon, england
    MS-Off Ver
    Excel 2019 / Windows 10
    Posts
    4,876

    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 2010
    Posts
    120

    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
    Ipswich, England
    MS-Off Ver
    Excel 2016 (Win 10 - Work) & 365 Subscription (Win 10 - Home)
    Posts
    27,600

    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 2010
    Posts
    120

    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 2010
    Posts
    120

    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
    Ipswich, England
    MS-Off Ver
    Excel 2016 (Win 10 - Work) & 365 Subscription (Win 10 - Home)
    Posts
    27,600

    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)

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