First if you using Integer the compiler will translate your number 101 (dec) to binary but that’s only for your general information.
Now for your problem – you can convert from binary to dec by using the C language.
I don’t remember the exact syntax but you can check the on MSDN (
http://msdn.microsoft.com/) for example a number that have the following prefix: 0x is hexadecimal number.
Then what you need to do is to take a binary number and convert it to integer.
If you are planning to create your self an algorithm then your should do something like that:
Int MyNumber = 101; // the same as 0101 or 00000000101
Int hundreds = MyNumber%100 // this sign % divide the number and leaves you with the number after the dot – 101%100 = 1 -> 101/100 =1.01
Int Tens = (MyNumber – hundreds)%10
Int Ones = MyNumber – hundreds – Tens
// now to convert you do this
Int BNumber = hundreds*4 +Tens*2 + Ones*1
My suggestion to you is: if you are planning to learn C – take it easy don’t be stress and try to learn your self as much as possible (don’t relay only on the teachers in school) – you can start by reading the following pdf file