This week's book giveaways are in the Refactoring and Agile forums.We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!

# negative numbers-2

Gautam Sewani
Ranch Hand
Posts: 93
If I am giving the following number in Binary,and have to convert it to decimal,then what is the method for it?
11000111

Jamal Hasanov
Ranch Hand
Posts: 411
1[B] 1 0 0 0 1 1 1
7 6 5 4 3 2 1 0
1*2^7+1*2^6+0*2^5+0*2^4+0*2^3+1*2^2+1*2^1+1*2^0=
128+64+0+0+0+4+2+1=199
Best regards,
Jamal Hasanov
www.j-think.com

Jamal Hasanov
Ranch Hand
Posts: 411
1 1 0 0 0 1[B] [B]1 1
7 6 5 4 3 2 1 0
1*2^7+1*2^6+0*2^5+0*2^4+0*2^3+1*2^2+1*2^1+1*2^0=
128+64+0+0+0+4+2+1=199
Best regards,
Jamal Hasanov
www.j-think.com

Jamal Hasanov
Ranch Hand
Posts: 411
Please ignore previous posts - Some errors
1 1 0 0 0 1 1 1
7 6 5 4 3 2 1 0
Easy method :
If first digit is 1 (and size is maximal, for example: 8 in byte,16 in word,etc)
-(1*2^7+1*2^6+0*2^5+0*2^4+0*2^3+1*2^2+1*2^1+1*2^0)=
128-64-0-0-0-4-2-1=-57
Best regards,
Jamal Hasanov
www.j-think.com