327jiw
Last Updated: February 25, 2016
·
4.433K
· tomgco

2's Complement in Javascript

My message to checksum:

var d = 0x0a + 0x80 + 0x04 + 0x06 + 0x20 + 0xff + 0xff

Represented as Base 16:

(~d + 1 >>> 0).toString(16)

or Binary:

(~d + 1 >>> 0).toString(2)

2 Responses
Add your response

3485

This should have more likes, reminding me of good ol' times at CS 101.

over 1 year ago ·
17757

Perfect for UPB command checksums!

over 1 year ago ·