NaN vs. Inf

5 次查看(过去 30 天)
Laurence Lurio
Laurence Lurio 2011-12-31
Why is
1/0 = Inf
but
[1,0]./[1,0] = [1 NaN]
shouldn't it be [1 Inf]?

采纳的回答

Image Analyst
Image Analyst 2011-12-31
1/0 is infinity, but 0/0 is not infinity nor is it zero - it's just undefined (NaN).
  1 个评论
Matt Tearle
Matt Tearle 2011-12-31
And if you want to know *why*, think in terms of limits. lim_{x->0} 1/x = infinity. But lim_{x->0} x^2/x = 0, lim_{x->0} x/x = 1, and lim_{x_>0} x/x^2 = infinity. So there's no way to determine what a "0/0" limit might be. Hence, it's undefined (NaN).
Similarly, Inf + Inf = Inf, but Inf - Inf = NaN.

请先登录,再进行评论。

更多回答(2 个)

Jose Jeremias Caballero
Hi.
[1,0]./[1,0]= [1/1,0/0]=[1,NaN]
  1 个评论
Jan
Jan 2012-1-1
The question is, why 0/0=NaN and not Inf.

请先登录,再进行评论。


Jose Jeremias Caballero

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by