two's complementary

(11 comments)
2004.02.03
Geekery of the Moment
So, this is really pretty geeky, even by my high standards. A lot of Atari 2600 coders on the Stella list thought that my ongoing JoustPong game could benefit mightily from "fractional movement", meaning the game keeps track of object speed and position in smaller-than-pixel detail. So I finally got up the guts to give the 16-bit-math it requires a try, and the results so far are very promising.

But I've had to reacquaint myself with a bit of semi-hardcore computery known as "Two's Complement Notation". It's a way of letting computers easily work with negative numbers, very cool in a mathy-geeky-philisophical way. But it's kind of a pain in the butt to convert a negatic number into binary this way by hand: you have to convert to binary, flip the bits, and then add 1. So I wanted an automated tool to do it for me, as I experiment with different values for Gravity and Flap Power in JoustPong.
Two's-Complement-O-Matic
decimal value:
number of bytes:

result:

break on bytes
high bytes first
I'm sure someone's already made this kind of tool, but I couldn't find it, and it was kind of fun to do by hand. I'm sure I did it the most difficult way possible, one binary digit at a time in javascript...still, I couldn't think of any other way to make it work with specific number of bytes.


Cartoon of the Moment

Harharhar, get it?

Highlight the following text for the explanation (or hit Ctrl-A), but think about it for a bit first:
It's a two...saying something nice...a compliment in fact...two's compliment...look at the rest of the page...get it now? Look, I didn't say it was very good. The "harharhar" was sarcastic.



Article of the Moment
More fodder for my neuroses, The Pentagon's Weather Nightmare, strategizing about what to do if Climate Change et al. brings us to the brink of a Mad Max-esque scenario...


Quick Link of the Moment
Fun with state shapes.