# Truncating a number to cancel any latent digits beyond 2

1. ## 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.``
Scott

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

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

3. ## 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. ## 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

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

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)

6. ## 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. ## 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. ## 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!!!

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

#### 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