6 ms·
It's the same with JavaScript regardless of whether you use == or === 9223372036854775807 == 9223372036854775808 true 9223372036854775807 === 92233720368547
by ndefinite 14y ago
It's the same with JavaScript regardless of whether you use == or ===
9223372036854775807 == 9223372036854775808
true
9223372036854775807 === 9223372036854775808
true
- tsuraan 14y agoThe difference being that the php code sample is trying to compare two strings.
- eblume 14y agoPerhaps those two lines are the same in JS and PHP (I do not have PHP installed so I can't confirm, but I do have node installed): > 9223372036854775807 == 9223372036854775808 true > 9223372036854775807 === 9223372036854775808 true However, that is not the two lines written about in this post. The following works as one would expect on JS, but (I assume, based on the report) not in PHP: > "9223372036854775807" == "9223372036854775808" false > "9223372036854775807" === "9223372036854775808" false
- ndefinite 14y agoah, I see. I missed that. I just checked in chrome's console and see false for both when they're strings.
- debacle 14y agoJavaScript doesn't have an fixed integer data type.
- aGHz 14y agoWhile this comment is beside the point, I'm still curious why this version works the way it does. I may be missing something obvious, but why does JS think those two integers are the same?
- mkup 14y agoProbably due to implicit conversion to floating point format. After conversion, mantissa and exponent are the same, and least significant bits are truncated during conversion.
- burgerbrain 14y agoIs "javascript does it too" supposed to be a defence?
- ndefinite 14y agoMore of an observation than anything else. I don't actually use PHP but find these recent PHP focused articles are helping me learn at thing or two about languages I do use.
- burgerbrain 14y agoFair enough.
- deleted 14y ago[deleted]