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)
Written by Tom Gallacher
Related protips
2 Responses

This should have more likes, reminding me of good ol' times at CS 101.
over 1 year ago
·

Perfect for UPB command checksums!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Checksum
Authors

tomgco
10.26K

trinitronx
4.284K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#