Created
February 22, 2019 15:04
-
-
Save RedDragon55/00bb3b54d468da70de957f30dc16f379 to your computer and use it in GitHub Desktop.
Revisions
-
RedDragon55 created this gist
Feb 22, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ function ToInteger(x) { x = Number(x); return x < 0 ? Math.ceil(x) : Math.floor(x); } function modulo(a, b) { return a - Math.floor(a/b)*b; } function ToUint8(x) { return modulo(ToInteger(x), Math.pow(2, 8)); } function ToInt8(x) { var uint8 = ToUint8(x); if (uint8 >= Math.pow(2, 7)) { return uint8 - Math.pow(2, 8) } else { return uint8; } } console.log(ToInt8(parseInt("80", 16)))