Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 2 个指标,并试图找出它们之间平均值的百分比差异,100*(m1+m2)/m1但这显然会产生NaN如果m1变为零。
100*(m1+m2)/m1
NaN
m1
如果我不想在指标变为零时发出警报,我应该如何处理这种情况?
bools bosun 具有类似短路的行为。由于 Bosun 的表达式语言缺少 if 语句,因此需要先使用 bool 运算查看除数是否为 0:
$foo = 0 $foo && 1/$foo
由于 $foo 为零,因此该语句“不正确”,因此 1/$foo 未计入最终计算: