Forum Discussion

Anastasiya T's avatar
Anastasiya T
Copper Contributor
Dec 22, 2017
Solved

Why Simple Formula Adding Two Cells Won't Work?

Hi. Could you please advise, why so simple formula like =E20+G20 won't work in case if number in cell G20 negative, but same value as in E20? In case of other number combinations it works.

 

Thank you.

  • SergeiBaklan's avatar
    SergeiBaklan
    Dec 26, 2017

    Floating point operations usually give side effect around zero result expected, especially with logical operations. Well known example is

    =1*(0.5-0.4-0.1)

    which returns -2.78E-17. With this

    =(1*(0.5-0.4-0.1)=0) returns FALSE
    however
    =( (1+1*(0.5-0.4-0.1))=1) returns TRUE

     

5 Replies

  • Deleted's avatar
    Deleted
    Not applicable

    Hi Anastasiya,

     

    Do you mean the result of E20 + G20 is showing up as zero? If yes, then that is simple arithmetic. Assuming E20 has 5 and G20 has -5, E20 + G20 = 5+(-5) = 5-5 = 0.
    If you have a different view of what you are asking for, you might want to share a screenshot of an example.

    Thanks,
    Bala..

    • Anastasiya T's avatar
      Anastasiya T
      Copper Contributor

      Not, of cause it is not so simple. 0, that what I expected it to be, and there was something strange. And actually may be this is not so simple formula as I called it, as in first cell was formula as well. But I just remembered something from years ago, and figured it. 

      • SergeiBaklan's avatar
        SergeiBaklan
        Diamond Contributor

        Floating point operations usually give side effect around zero result expected, especially with logical operations. Well known example is

        =1*(0.5-0.4-0.1)

        which returns -2.78E-17. With this

        =(1*(0.5-0.4-0.1)=0) returns FALSE
        however
        =( (1+1*(0.5-0.4-0.1))=1) returns TRUE