This Gist was automatically created by Carbide, a free online programming environment.
Last active
October 11, 2018 09:52
-
-
Save carbide-public/917edeea2a3d5e611a44a405331a8c4c to your computer and use it in GitHub Desktop.
untitled
This file contains 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 characters
const a = "03E8"//.split('').reverse().join('') | |
const b = "ff9c"//.split('').reverse().join('') | |
// Functions | |
let tohx = s => parseInt(s, 16) | |
let twos = s => s.split('').map(c => (15 - tohx(c)).toString(16)).join('') | |
let ttwos = s => twos(twos(s)) | |
let twosinc = s => (tohx(twos(s)) + 1).toString(16) | |
let pad = s => ("0000" + s).slice(-a.length) | |
// Pad with F if inverted | |
// ungigned mul | |
let mul = (tohx(a) * tohx(b)).toString(16) | |
// signed imul | |
let aa = | |
let bb = twosinc(b) | |
aa = pad(aa) | |
bb = pad(bb) | |
let imul = ((tohx(aa)) * (tohx(bb))).toString(16) | |
let lol = twos(imul) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment