Javascript 除法为0时如何检查无穷大
我想检查给定的结果是否等于无穷大。我如何才能正确地检查它Javascript 除法为0时如何检查无穷大,javascript,html,Javascript,Html,我想检查给定的结果是否等于无穷大。我如何才能正确地检查它 <input type="text" name="answer" id="t" onkeyup="withoutLat(this);withoutCyr(this);checkInfinity(this);" placeholder="Enter data" autofocus> function checkInfinity(value) { var value = calcul
<input type="text" name="answer" id="t" onkeyup="withoutLat(this);withoutCyr(this);checkInfinity(this);" placeholder="Enter data" autofocus>
function checkInfinity(value)
{
var value = calculator.answer.value;
if (value == Number.POSITIVE_INFINITY || value == Number.NEGATIVE_INFINITY)
{
alert("Помилка ділення на нуль")
}
}
函数检查无穷大(值)
{
var值=calculator.answer.value;
如果(值==Number.POSITIVE | |值==Number.NEGATIVE |
{
警报(“ПМаааааааааа”)
}
}
看看这个
那你呢
没有。只有
0/0
会导致NaN
,因为它比其他数字除以零更像是“不确定的一级”x/0
将导致x的sgn(x)*无穷大=0,即5/0
是数字。正无穷
和(-5)/0
是数字。负无穷
。
isFinite(12) //true
isFinite(12/0) //false
var result = 10 / 0;
if (result === Infinity) {
alert('Atata!')
}