Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Negative binary numbers problem

Status
Not open for further replies.

engr.waqas

Full Member level 3
Joined
Jul 21, 2009
Messages
172
Helped
13
Reputation
26
Reaction score
10
Trophy points
1,298
Location
karachi,Pakistan
Activity points
2,342
in using 2's complement the -12 in binary is 11110100.
but if i convert 11110100 to decimal using calculator gives me 244.
So if i have the binary number 11110100 then how can i find that is it -12 or 244?
 

the binary number you enter in calculator is taken as
unsigned positive 8bit binary. so it gives its value.

unless your calculator has a mode to enter the 2's complement numbers it will be the result.

for you the binary shown is '2's complement'.

srizbf
27thjune2010
 

it depends upon the instruction that is used for the number.

srizbf
27thjune2010
 

Whenever you are writing software, you are usually in control of how numbers are handled. In C you define a number as unsigned or not. In assembler the micro may have instructions which operate signed or unsigned. You need to make sure you use the correct instructions with the right variables. In other words, if you have defined a variable as signed, you cannot later use instructions meant for unsigned data without first performing some conversion. You also need to be a careful changing the number of a bits. An 8 bit signed number converted to 16 bits needs 1s adding to the upper byte if the 8 bit number was negative.

Keith
 

    engr.waqas

    Points: 2
    Helpful Answer Positive Rating
Glad to help. See the www link on my profile - that is what I do. It may look like a large company, but it is all me ;)

Keith
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top