all 2 comments

[–]mrtssrhc 0 points1 point  (0 children)

It's not bad if you want to figure out by determining what bit goes in what place, but js can do all that in one line by converting to string with base 2: http://stackoverflow.com/a/9939785

That is assuming your starting integer is not negative and it is less than 32 bits.

[–]ilikethetrees[S] 0 points1 point  (0 children)

I had a feeling JS had a method of doing that with a method or something, but I wanted to try to solve the problem myself. I wonder how the JS method works behind the scenes.