+ Reply to Thread
Results 1 to 7 of 7

=ROUND question

  1. #1
    Registered User
    Join Date
    12-13-2024
    Location
    NJ
    MS-Off Ver
    365
    Posts
    30

    =ROUND question

    I found this response in another forum and it worked for me, but I don't completely understand why...


    You can't perform this kind of comparison using floating point numbers without rounding the values first due to the limited precision within Excel and the way computers store values in Binary. Hence you should round both numbers first:
    =ROUND(A1,4)=ROUND(B1,4)
    Using EXACT is unnecessary - you should only use EXACT for string comparisons where case sensitivity is important.


    My question is - the 2 cells I was comparing did have the exact same € amt in them via formulas, but the comparison field kept says FALSE till I plugged in the above formula instead. Can someone explain a bit more in depth why and also, what are the 4's doing in the formula?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,237

    Re: =ROUND question

    the 2 cells I was comparing did have the exact same € amt in them via formulas
    Almost certainly, if you increase the number of decimal places displayed, you will find the numbers are not the exact same amount.

    The 4 is rounding the numbers to 4 decimal places.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    12-13-2024
    Location
    NJ
    MS-Off Ver
    365
    Posts
    30

    Re: =ROUND question

    Both cells are simple currency fields with 2 decimals.

    That's interesting though

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,699

    Re: =ROUND question

    Quote Originally Posted by mrguinness View Post
    My question is - the 2 cells I was comparing did have the exact same € amt in them via formulas, but the comparison field kept says FALSE till I plugged in the above formula instead. Can someone explain a bit more in depth why and also, what are the 4's doing in the formula?
    This might be more "in depth" than you need but this article explains why Excel's calculations can sometimes produce incorrect results

    https://learn.microsoft.com/en-us/of...ccurate-result
    Audere est facere

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,237

    Re: =ROUND question

    You are displaying two decimal places. That doesn't mean there are only two decimal places.

    As I said, increase the number of decimal places. Eventually, you will (almost certainly) see a difference in the calculated amounts.

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,830

    Re: =ROUND question

    I'll bet the cells you were comparing did not have the exact same amounts. Format the cells to show 15 decimal places and let us know what you see.

    Without knowing the context of what you quoted, I have no idea why they rounded to 4 decimal places. If you are dealing with currency, you are almost always going to round to 2 places, unless you are talking about unit pricing that has greater precision than that, like gasoline.

    The reason you have to do the rounding has to do with trying to calculate using decimal numbers in a computer that does binary arithmetic. This is true of all binary computers, not specific to Excel. It gets rather technical and I'm assuming you don't want to go that deep. But here is an analogy. Suppose I want to do the division 1/3. In base 3, it's 0.1, very simple. But in decimal notation, you get a repeating decimal. You cannot represent 1/3 exactly in base 10. Similarly, you cannot represent 1/3 exactly as a binary number. When you do two different calculations and it looks like you are getting the same number, it might not really be the same number because Excel will maintain only 15 significant digits, and that very last digit will have to be rounded. Depending on the value and how the calculation is done, it might round in either direction.

    If you really want more detail I'll refer you to an IEEE standard on real number representation.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,237

    Re: =ROUND question

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon (Next to Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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: 5
    Last Post: 05-28-2022, 04:42 PM
  2. [SOLVED] How to PRESENT round-down, but not perform round-down function?
    By superlative in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-02-2019, 12:06 PM
  3. Round and SUMIF Question
    By GCLIFTON in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-02-2016, 02:22 PM
  4. [SOLVED] Custom formulas that will round up when a condition is met or round down
    By cinstanl in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-20-2016, 01:32 PM
  5. Replies: 2
    Last Post: 12-06-2014, 01:58 PM
  6. [SOLVED] How to round to nearest .01 and round down if thousands place is .005
    By dredre609 in forum Excel General
    Replies: 5
    Last Post: 09-29-2014, 11:47 AM
  7. stupid round question
    By Sergei D in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-07-2006, 12:55 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