Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does JavaScript returns that?

Tags:

javascript

So, my question is why:

1.7976931348623157E+308 > 10^16 returns 17 in Google Chrome,
and (1.7976931348623157E+308) > (10^16) returns true?

Because it looks like these operations are the same.

like image 568
Vyacheslav Avatar asked Nov 22 '25 14:11

Vyacheslav


1 Answers

The first expression is equivalent to

(1.7976931348623157E+308 > 10) ^ 16

or

true ^ 16

Which seems strange, until you realize that

true == 1

is true.

like image 200
Scott Hunter Avatar answered Nov 25 '25 03:11

Scott Hunter