I'm working on a page that processes IP address information, but it's choking on the fact that integers are signed. I am using bitwise operators to speed it up, but the 64th bit (signed/unsigned flag) is messing it up.
Is there any way to force a number to be unsigned in Javascript? It seems to work fine, until subnet is greater than 30, or less than 2.
Try this:
<html>
<body>
<script type='text/javascript'>
document.write( (1 << 30) +"<br/>");
document.write( (1 << 31) +"<br/>");
document.write( (1 << 32) +"<br/>");
</script>
</body>
</html>
Result:
1073741824 -2147483648 1
int
andunsigned int
can have as little as 16 bits, and as much as the implementer wants in C. Usually they are as wide as the integer registers, from 16 to 64 bits. – Modiolus