Skip to content

Instantly share code, notes, and snippets.

@carbide-public
Last active October 11, 2018 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carbide-public/917edeea2a3d5e611a44a405331a8c4c to your computer and use it in GitHub Desktop.
Save carbide-public/917edeea2a3d5e611a44a405331a8c4c to your computer and use it in GitHub Desktop.
untitled
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