Hi,
I am trying convert a byte array to a number and for large numbers,
I see that the bit shift is giving -ve results.
Can one of you please why we see this issue?
For example,
<script language="JavaScript">
var myVar = [COLOR="#0000FF"]1000000[/COLOR];
document.write("Bit shft Result: " + (myVar << 8));
document.write("<br>");
document.write("Multiplication Result: " + parseInt(myVar *256));
</script>
Output:
Bit shft Result : 256000000
Multiplication Result: 256000000
Upon adding one more zero to myVar, you see the issue I am talking about
<script language="JavaScript">
var myVar = [COLOR="#0000FF"]1000000[/COLOR][B][COLOR="#FF0000"]0[/COLOR][/B];
document.write("Bit shft Result: " + (myVar << 8));
document.write("<br>");
document.write("Multiplication Result: " + parseInt(myVar *256));
</script>
Output:
Bit shft Result: -1734967296
Multiplication Result: 2560000000
Regards,
Sunny