What does — do in Excel formulas?

后端 未结 4 1062
失恋的感觉
失恋的感觉 2020-11-29 10:07

Trying to decipher some Excel formulas and I see some stuff like SUMPRODUCT(--Left(...)...)

What is the -- doing? Naturally seems like decrementing to me but couldn\

4条回答
  •  旧时难觅i
    2020-11-29 10:51

    The unary operator (-) is a shorthand method to convert a true/false statement into -1/0.

    A single operator will convert -(true) into -1, so a double unary operator is used to convert that back into 1:

    -(-(true)) = -(-(1)) = 1
    -(-(false)) = -(-(0)) = 0
    

提交回复
热议问题