Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NAN and Infinity in javascript mathematical operations [duplicate]

0 / 0 outputs NaN while 1 / 0 outputs Infinity

How javascript evaluates the first mathematical operation?

like image 829
khaled fares Avatar asked Apr 19 '26 15:04

khaled fares


1 Answers

As per spec

0 / 0 outputs NaN because

Division of a zero by a zero results in NaN; division of zero by any other finite value results in zero, with the sign determined by the rule already stated above.

and 1 / 0 outputs Infinity because

Division of a nonzero finite value by a zero results in a signed infinity. The sign is determined by the rule already stated above.

Point 7 and 8 in the section 12.6.3.2 Applying the / Operator (unordered list)

like image 63
gurvinder372 Avatar answered Apr 22 '26 05:04

gurvinder372



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!