Excel 公式中的 -- 有何作用?
尝试破译一些 Excel 公式,我看到一些类似 SUMPRODUCT(--Left(...)...) 的东西,
-- 在做什么?当然,对我来说似乎是递减,但找不到任何相关文档。
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't find any documentation on it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
双破折号称为双一元运算符。
试试这个链接:为什么在 SUMPRODUCT 公式中使用 --
具体来说:
单个一元运算符 (-) 将 true/false 值强制转换为 -1/0。通过使用双一元运算符,我们再次将值强制为 1/0。
The double-dash is known as a double unary operator.
Try this link: Why use -- in SUMPRODUCT formulae
Specifically:
A single unary operator (-) coerces true/false values into -1/0. By using the double unary operaor, we coerce the values again to 1/0.
一元运算符 (-) 是将真/假语句转换为 -1/0 的简写方法。
单个运算符会将 -(true) 转换为 -1,因此使用双一元运算符将其转换回 1:
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:
我使用 SUMPRODUCT 一段时间了,并且始终使用
*
符号而不是--
。我确信我问了与您相同的问题,但我不记得他们给我的原因,但我被告知实际上并不需要--
作为 sumproduct没有它就可以很好地管理自己。不管怎样,
=sumproduct(()*()*()*())
一直对我有用,而且不那么令人困惑。I've been using SUMPRODUCT for a while and have always used the
*
symbol instead of the--
. I'm sure I asked the same question you've asked, but I can't remember the reason they gave me, but I was told that there wasn't really a need for--
as sumproduct managed itself quite well without the it.Anyway,
=sumproduct(()*()*()*())
has always worked for me, and it's less confusing.布尔值TRUE和FALSE在Excel中被视为1和0,但我们需要将它们进行转换。要将它们转换为数字 1 或 0,请进行一些数学运算。一元运算符对布尔值取反(数学运算),因此将布尔值转换为数字。 TRUE * FALSE = 0 时同样有效
Boolean values TRUE and FALSE in excel are treated as 1 and 0, but we need to convert them. To convert them into numbers 1 or 0, do some mathematical operation. The Unary operator negates the boolean (math operation), hence, converts the boolean to number. Same works in TRUE * FALSE = 0