Did you know, that in memory, your variable is held as raw data which is represented as binary? So, in all actuality, your variable is already in binary.
Also, did you know that there isn't a direct way to print this out? Well, you can but its not very fast or as fast as it should be. Our bitset container actually helps us with this but I'm not sure of the common methods it uses:
http://codepad.org/JiOvAY8C
EDIT: Here's an example with templates: http://codepad.org/K685Y208
Careful though, it errors if you give it a type that can't handle the integer you gave which is actually a good thing.
Complement to one: just invert the bits (xor 111111....).
Complement to two: invert the bits and add one. If you want to do it on the fly, pass the carry as an extra parameter and do primary arithmetic
Traverse your array.
'invert' every cell. How much do I need to be the greatest digit of my base?
Now you have complement to 1(in base 2) or complement to 9 (in base 10)
if you add 1 (in that base), you will have the complement to base.
the issue is my above i am able to convert to any base... so if i were to traverse it will it have any effect to my actual results and the result after complement?
i need to have
1. actual result (be it base 2/8/10/16)
2. after complement 1 (in binary)
3. after complement 2 (in binary)
For the binary representation of complement 1 you just need to invert (0->1 and 1->0).
For complement 2 you add one to the complement 1(using a carry).
For convert to the other bases, you could pass trough base 10, and with that number to 8 and 16