Why is 0 divided by 0 equals NaN? in js

clipboard.png


0NaN

clipboard.png

Dec.24,2021

  1. any value divided by 0 will cause an error ( mathematical ) and terminate program execution, but in JavaScript, NaN will be returned, which does not affect the following programs
  2. .
  3. A number greater than 0 divided by 0 results in infinity. Infinity is displayed in js.

first of all, NaN is a special value in js, meaning "non-numeric" (but it is typeof or number); next, 0 code > getting NaN is defined:

clipboard.png
( provenance )

Finally, if you don't want to show up as NaN, you can judge the result. A relatively simple way is to go to Eustia to find the isNaN judgment function directly, click source to see the source code directly, and then write to add a judgment at the end of your program.

in fact, as far as the program is concerned, a judgment logic should be added here to see if the output is within the expected range (in fact, the input should also be checked).


is there another question for things like this? Just make your own judgment and deal with it
or else the subject can invent a language of zero zero by himself


didn't the primary school teacher say that zero cannot be divided? / can't you be the denominator?


first of all, it is a math problem. 0 cannot be used as a divisor.
so any number divided by 0 will report an error.
js has been optimized, and 0 will return NaN


how to learn math? Judge alone


what original insights you expect before clicking.
after reading it, I found that there are so many dissenting votes in deserve it

Menu