1/0 = 'inf' why?

조회 수: 21 (최근 30일)
Hwi Won Kim
Hwi Won Kim 2017년 3월 15일
편집: Bruno Luong 2019년 7월 2일
1/0 is unable. why did you write inf. Why is not Nan?
  댓글 수: 2
Rik
Rik 2017년 3월 15일
It just is. I suspect it has something to do with finding the limit for a/b with 'b' approaching 0 and 'a' a non-zero value.
KSSV
KSSV 2017년 3월 15일
Read wiki article it explains. https://en.wikipedia.org/wiki/Division_by_zero

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2017년 3월 15일
편집: Jan 2017년 3월 15일
This is the IEEE754 standard:
*Exception handling*
Division by zero (an operation on finite operands gives an exact infinite
result, e.g., 1/0 or log(0)) (returns ±infinity by default).

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 3월 15일
1/0 is the limit of 1/(1/N) as N approaches infinity. But for any finite N, 1/(1/N) is N. So as N approaches infinity, the value approaches infinity.
You could start from the other side of 0, in which case you could conclude that the results should be negative infinity.
There are thus two possible results, infinity and negative infinity. You might say that is enough to declare the result should be nan. But there are only the two possible results and infinity is pretty useful, so IEEE declared that a positive value decided by 0 would be positive infinity and a negative value divided by 0 would be negative infinity. It is useful.
The other cases such as 0/0 or infinity minus infinity that produce nan have stronger reasons for being indeterminate.
  댓글 수: 4
Jan
Jan 2019년 7월 2일
@darova: All users of this forum are potential MVP in the future. But all discussions are welcome. Sometimes a questions for clarifications helps to improve an explanation or to reveal a missunderstanding.
Do not overestimate the MVP status. I got it by posting many answers over the decades, but it is still an efficient idea to think twice instead of debating with Walter :-)
Bruno Luong
Bruno Luong 2019년 7월 2일
편집: Bruno Luong 2019년 7월 2일
There is no rigourous consistent mathemathical justtification so such result.
Jan is correct, because IEEE standard states it like this.
The result is actually
Inf * (bit-sign of numerator) * (bit-sign of 0-denominator).
>> z=0
z =
0
>> z==-z
ans =
logical
1
>> 1/z==1/(-z) % compare Inf and -Inf
ans =
logical
0
>>

댓글을 달려면 로그인하십시오.

카테고리

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