I have the folowing code:
<a href="javascript:Add(23905762501722146)">Click</a>
function Add(id) {
alert(id);
}
The value in the alert is 23905762501722144 (-2) from the original value.
Why does this happen?
I have the folowing code:
<a href="javascript:Add(23905762501722146)">Click</a>
function Add(id) {
alert(id);
}
The value in the alert is 23905762501722144 (-2) from the original value.
Why does this happen?
log2(23905762501722146) ~= 54.408
JavaScript stores all numbers - including integers - as double precision floats. Double precision mantissa/significand contains 52 bits of information, so some information gets lost storing so long/precise number as you have.
Because 23905762501722144 is to big to represent as integer value... try sending it as string value.