Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

atoi javascript

   function atoi(erin, isunsigned) {
      var retnum = 0;
      for (var i = 0; i < 2; i++) {
        retnum += erin.charCodeAt(i) << (i * 8);  
      }
     
      return (isunsigned == true) ? Int16(retnum) : retnum;
    }

	var UInt16 = function (value) {
      return (value & 0xFFFF);
    };

    var Int16 = function (value) {
      var ref = UInt16(value);
      return (ref > 0x7FFF) ? ref - 0x10000 : ref;
    };

 
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #atoi #javascript
ADD COMMENT
Topic
Name
1+8 =