javascript - Why do I get the wrong id somewhere, somehow? -
okay so, source code.
var newrealid = <? print($_session["mysteamid"]) ?>; alert("my id = " + <? print($_session["mysteamid"]) ?>);
and when inspect site or view source code following code
var newrealid = 76561198061310076; alert(76561198061310076);
which correct output, however, alert box visually in chrome is:
my id = 76561198061310080
i have absolutely no idea , i've been stuck here ages..
the issue because value you're using beyond max_safe_integer
js allows:
console.log(76561198061310076); console.log(number.max_safe_integer)
due number coerced floating point , again. in turn introduces rounding errors, accounts discrepancy see in result.
assuming don't need use mathematical operations on value, convert string in output:
var newrealid = '<? print($_session["mysteamid"]) ?>';
Comments
Post a Comment